public bool UpdateInventory(InventoryEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Inventory
                    .Single(e => e.ItemID == model.ItemID);

                entity.ItemID          = model.ItemID;
                entity.ItemName        = model.ItemName;
                entity.SkuNumber       = model.SkuNumber;
                entity.ItemDescription = model.ItemDescription;
                entity.ItemPrice       = model.ItemPrice;
                entity.TypeOfItem      = model.TypeOfItem;

                if (model.Photo != null)
                {
                    MemoryStream target = new MemoryStream();
                    model.Photo.InputStream.CopyTo(target);
                    byte[] data = target.ToArray();

                    entity.Photo = data;
                }

                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Edit(int id, InventoryEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.ItemID != id)
            {
                ModelState.AddModelError("", "ID Mismatch");
                return(View(model));
            }

            var service = CreateInventoryService();

            if (service.UpdateInventory(model))
            {
                TempData["SaveRestult"] = "Your Inventory item was updated.";

                return(RedirectToAction("Details", new { id = id }));
            }

            ModelState.AddModelError("", "Your Inventory item could not be updated.");

            return(View(model));
        }
        public ActionResult Edit(int id, InventoryEdit item)
        {
            if (!ModelState.IsValid)
            {
                return(View(item));
            }

            if (item.InventoryId != id)
            {
                ModelState.AddModelError("", "Id mismatch.");
                return(View(item));
            }

            var service   = new InventoryService(GetGuid());
            var inventory = service.GetInventoryItemById(id);

            if (service.UpdateInventoryItem(item))
            {
                TempData["SaveResult"] = "Your item was updated.";
                return(RedirectToAction("Index", new { id = inventory.CharacterId }));
            }

            ModelState.AddModelError("", "Your item could not be updated.");
            return(View(item));
        }
 public InventoryEditController(InventoryEdit screen, ProductModel product, InventoryScreen inventoryScreen)
 {
     _dbc                  = DatabaseController.Instance;
     this._product         = product;
     this._screen          = screen;
     this._inventoryScreen = inventoryScreen;
     FillWithProductInfo();
 }
示例#5
0
 public bool UpdateInventory(InventoryEdit model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var entity = ctx.Inventories.Single(e => e.InventoryID == model.InventoryId);
         entity.InventoryID = model.InventoryId;
         entity.ProductId   = model.ProductId;
         entity.Quantity    = model.Quantity;
         return(ctx.SaveChanges() == 1);
     }
 }
 public bool UpdateInventory(InventoryEdit model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var entity = ctx.Inventories.Single(e => e.InventoryID == model.InventoryID && e.VideoGameID == model.VideoGameID);
         entity.InventoryItem   = model.InventoryItem;
         entity.ItemQuantity    = model.ItemQuantity;
         entity.ItemDescription = model.ItemDescription;
         entity.ItemAcquired    = model.ItemAcquired;
         return(ctx.SaveChanges() == 1);
     }
 }
        //GET:
        public ActionResult Edit(int id)
        {
            var service = CreateInventoryService();
            var detail  = service.GetInventoryById(id);
            var model   = new InventoryEdit
            {
                InventoryId = detail.InventoryId,
                ProductId   = detail.ProductId,
                Quantity    = detail.Quantity
            };

            return(View(model));
        }
        public bool UpdateInventoryItem(InventoryEdit item)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity = ctx.Inventories.Single(e => e.OwnerId == _ownerId && e.InventoryId == item.InventoryId);

                entity.ItemName     = item.ItemName;
                entity.ItemQuantity = item.ItemQuantity;
                entity.ItemType     = item.ItemType;

                return(ctx.SaveChanges() == 1);
            }
        }
        public ActionResult Edit(int id)
        {
            var service = new InventoryService(GetGuid()).GetInventoryItemById(id);

            var model = new InventoryEdit
            {
                CharacterId  = service.CharacterId,
                InventoryId  = service.InventoryId,
                ItemName     = service.ItemName,
                ItemQuantity = service.ItemQuantity,
                ItemType     = service.ItemType
            };

            return(View(model));
        }
示例#10
0
        public ActionResult InventoryEdit(int id)
        {
            var service = CreateInventoryService();
            var detail  = service.InventoryDetails(id);
            var model   = new InventoryEdit
            {
                InventoryID     = detail.InventoryID,
                InventoryItem   = detail.InventoryItem,
                ItemQuantity    = detail.ItemQuantity,
                ItemDescription = detail.ItemDescription,
                ItemAcquired    = detail.ItemAcquired,
                VideoGameID     = detail.VideoGameID
            };

            return(View(model));
        }
        public ActionResult Edit(int id)
        {
            var service = CreateInventoryService();
            var detail  = service.GetInventoryById(id);
            var model   =
                new InventoryEdit
            {
                InventoryId     = detail.InventoryId,
                InventoryLiquor = detail.InventoryLiquor,
                InventoryJuice  = detail.InventoryJuice,
                InventoryFruit  = detail.InventoryFruit,
                InventoryOther  = detail.InventoryOther
            };

            return(View(model));
        }
        public ActionResult Edit(int id)
        {
            var service = CreateInventoryService();
            var detail  = service.GetInventoryById(id);
            var model   =
                new InventoryEdit
            {
                ItemID          = detail.ItemID,
                ItemName        = detail.ItemName,
                SkuNumber       = detail.SkuNumber,
                ItemDescription = detail.ItemDescription,
                ItemPrice       = detail.ItemPrice
            };

            return(View(model));
        }
        public bool UpdateInventory(InventoryEdit model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var entity =
                    ctx
                    .Inventory
                    .Single(e => e.InventoryId == model.InventoryId && e.OwnerId == _userId);

                entity.InventoryId = model.InventoryId;
                entity.Liquor      = model.InventoryLiquor;
                entity.Juice       = model.InventoryJuice;
                entity.Fruit       = model.InventoryFruit;
                entity.Other       = model.InventoryOther;

                return(ctx.SaveChanges() == 1);
            }
        }
        public OperationResult Edit(InventoryEdit edit)
        {
            var operation = new OperationResult();
            var inventory = _inventoryRepository.GetById(edit.Id);

            if (inventory == null)
            {
                return(operation.Fail(ApplicationMessages.NotFoundRecord));
            }

            if (_inventoryRepository.Exists(i => i.ProductId == edit.ProductId && i.Id != edit.Id))
            {
                return(operation.Fail(ApplicationMessages.DuplicateRecord));
            }

            inventory.Edit(edit.ProductId, edit.UnitPrice);
            _inventoryRepository.SaveChanges();
            return(operation.Success(ApplicationMessages.SuccessUpdate));
        }
        public ActionResult Edit(int id, InventoryEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            if (model.InventoryId != id)
            {
                ModelState.AddModelError("", "ID Mismatch");
                return(View(model));
            }
            var service = CreateInventoryService();

            if (service.UpdateInventory(model))
            {
                TempData["SaveResult"] = $"Your inventory was updated.";
                return(RedirectToAction("Index"));
            }
            ModelState.AddModelError("", $"Your inventory could not be updated.");
            return(View());
        }
        public ActionResult Edit(int id, InventoryEdit model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (model.InventoryId != id)
            {
                ModelState.AddModelError("", "Id Mismatch");
                return(View(model));
            }

            var service = CreateInventoryService();

            if (service.UpdateInventory(model))
            {
                TempData["SaveResult"] = "Your Inventory Addition was saved";
                return(RedirectToAction("Index"));
            }

            ModelState.AddModelError("", "Your inventory was not updated. Please try again.");
            return(View(model));
        }
        public JsonResult OnPostEdit(InventoryEdit edit)
        {
            var result = _inventoryApplication.Edit(edit);

            return(new JsonResult(result));
        }