Beispiel #1
0
        public async Task <IActionResult> InvItemEdit(InvItemModel model)
        {
            if (model.InventID == 0)
            {
                return(RedirectToAction("InventoryControl"));
            }

            var inventory = await _invManagement.GetInventorybyId(model.InventID);

            if (inventory == null)
            {
                return(RedirectToAction("InventoryControl"));
            }

            if (ModelState.IsValid)
            {
                inventory = await _invManagement.UpdateInvItemModel(inventory, model);

                SuccessNotification("The inventory data has been updated successfully.");

                return(RedirectToAction("InvItemEdit", "InventoryManagement",
                                        new { InventID = model.InventID }));
            }

            //if we got so far and something fail
            foreach (var item in (await _productManagementService.GetCategories((int)_workContext.CurrentCustomer.ClientId)))
            {
                model.AvailableCategory.Add(new SelectListItem {
                    Text = item.Category1, Value = item.Category1
                });
            }

            return(View(model));
        }
        public async Task <Inventory> UpdateInvItemModel(Inventory inventory, InvItemModel model)
        {
            inventory.Category       = model.Category;
            inventory.IqtyStock1     = model.IqtyStock1;
            inventory.IsellingPrice1 = model.IsellingPrice1;
            inventory.Ipo1           = model.Ipo1;
            inventory.Ipodate1       = model.Ipodate1;

            inventory.IqtyStock2     = model.IqtyStock2;
            inventory.IsellingPrice2 = model.IsellingPrice2;
            inventory.Ipo2           = model.Ipo2;
            inventory.Ipodate2       = model.Ipodate2;

            inventory.IqtyStock3     = model.IqtyStock3;
            inventory.IsellingPrice3 = model.IsellingPrice3;
            inventory.Ipo3           = model.Ipo3;
            inventory.Ipodate3       = model.Ipodate3;

            inventory.IqtyStock4     = model.IqtyStock4;
            inventory.IsellingPrice4 = model.IsellingPrice4;
            inventory.Ipo4           = model.Ipo4;
            inventory.Ipodate4       = model.Ipodate4;

            inventory.IqtyStock5     = model.IqtyStock5;
            inventory.IsellingPrice5 = model.IsellingPrice5;
            inventory.Ipo5           = model.Ipo5;
            inventory.Ipodate5       = model.Ipodate5;

            inventory.Ilocation = model.Ilocation;
            inventory.IonOrder  = model.IonOrder;
            inventory.DeptResp  = model.DeptResp;
            inventory.Reorder   = model.Reorder;
            inventory.MaxQty    = model.MaxQty;

            inventory.Ihighlight = model.Ihighlight;
            inventory.Invisible  = model.Invisible;

            inventory.Inote    = model.Inote;
            inventory.ClientId = (int)_workContext.CurrentCustomer.ClientId;

            await _inventoryRepository.UpdateAsync(inventory);

            //update item
            var item = _itemRepository.Table.Where(i => i.VitemId == inventory.VitemId).FirstOrDefault();

            if (model.Hide != null)
            {
                item.Hide = model.Hide;
            }

            await _itemRepository.UpdateAsync(item);

            return(inventory);
        }