public ActionResult Create([Bind(Include = "Id,Name,Adress")] Warehouse warehouse) { if (ModelState.IsValid) { warehouseRepository.CreateWarehouse(warehouse); return(RedirectToAction("Index")); } return(View(warehouse)); }
public Warehouse CreateWarehouse(Warehouse warehouse) { if (warehouse.MakeProductIds != null) { var makeProducts = _makeProductService.GetMakeProductByIds (warehouse.MakeProductIds); if (makeProducts.Any(a => a.Warehouse != null)) { throw new Exception(); } warehouse.MakeProduct = makeProducts; } return(_warehouseRepository.CreateWarehouse(warehouse)); }
public ActionResult CreateWarehouse(WarehouseViewModel warehouseViewModel) { //kusht nqs modeli eshte valid if (!ModelState.IsValid) { ModelState.AddModelError("", "Warehouse Error"); return(View()); } //ruajtja e te dhenave ne databaze _warehouseRepository.CreateWarehouse(warehouseViewModel); return(View(new WarehouseViewModel() { Sectors = _sectorRepository.allSectors() })); }