コード例 #1
0
        public void DecrementInventory(Model.Inventory inventory2BeUpdated)
        {
            Entity.Inventory oldInventory = _context.Inventories.Find(inventory2BeUpdated.InventoryId);

            // Console.WriteLine(oldInventory.ToString());
            // Console.WriteLine(oldInventory.ToString());

            // _context.Entry(oldInventory).CurrentValues.SetValues(inventory2BeUpdated);



            // Entity.Inventory oldInventory1 = _context.Inventories.Find(inventory2BeUpdated.InventoryId);


            oldInventory.InventoryQuantity = inventory2BeUpdated.InventoryQuantity - 1;


            // oldInventory1.InventoryQuantity = inventory2BeUpdated.InventoryTotal;

            // _context.Entry(oldInventory).CurrentValues.SetValues((inventory2BeUpdated));


            _context.SaveChanges();

            //     // _context.ChangeTracker.Clear();
        }
コード例 #2
0
        public void UpdateInventory(Model.Inventory inventory2BeUpdated)
        {
            Entity.Inventory oldInventory = _context.Inventories.Find(inventory2BeUpdated.InventoryId);

            _context.Entry(oldInventory).CurrentValues.SetValues(inventory2BeUpdated);


            Entity.Inventory oldInventory1 = _context.Inventories.Find(inventory2BeUpdated.InventoryId);


            oldInventory1.InventoryQuantity = inventory2BeUpdated.InventoryQuantity;

            // oldInventory1.InventoryQuantity = inventory2BeUpdated.InventoryTotal;

            _context.Entry(oldInventory).CurrentValues.SetValues((inventory2BeUpdated));


            _context.SaveChanges();

            //     // _context.ChangeTracker.Clear();
        }