コード例 #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 Model.Inventory GetInventory(int prod, int loc)
        {
            Entity.Inventory found = _context.Inventories.FirstOrDefault(inv => inv.InventoryNumber == prod && inv.InventoryCode == loc);
            if (found == null)
            {
                return(null);
            }
            return(new Model.Inventory(found.InventoryId, found.InventoryNumber, found.InventoryQuantity, found.InventoryCode));

            //     // _context.ChangeTracker.Clear();
        }
コード例 #3
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();
        }