public Model.Inventory ParseInventory(Entity.Inventory inventory)
 {
     return(new Model.Inventory
     {
         LocId = inventory.LocId,
         Id = inventory.Id
     });
 }
Example #2
0
 public Inventory UpdateInventory(Model.Inventory inventory, Model.Location location, Model.Product product)
 {
     Entity.Inventory updateInventory = _context.Inventories.Single(inven => inven.InventoryId == inventory.Id);
     updateInventory.Quantity = inventory.Quantity;
     _context.SaveChanges();
     Log.Information("DL persisted inventory update to DB");
     return(inventory);
 }
 public Model.Inventory ParseInventory(Entity.Inventory inventory)
 {
     return(new Model.Inventory
     {
         LocationIdentity = inventory.LocationIdentity,
         InventoryID = inventory.InventoryID,
         InventoryQuantity = inventory.InventoryQuantity
     });
 }
 //To-Do
 //Update inventory by productId
 public void UpdateInventory(Product product, int quantity)
 {
     Entity.Inventory oldItem = _context.Inventories.Find(product.Id);
     _context.Entry(oldItem).CurrentValues.SetValues(
         oldItem.Quantity = quantity
         );
     _context.SaveChanges();
     _context.ChangeTracker.Clear();
 }
Example #5
0
 public Inventory GetStoreInventory(Model.Inventory inventory)
 {
     Entity.Inventory found = _context.Inventories.FirstOrDefault(inven => inven.LocationId == inventory.LocationID && inven.ProductId == inventory.ProductID && inven.Quantity == inventory.Quantity);
     if (found == null)
     {
         return(null);
     }
     Log.Information("DL sent store inventory to BL");
     return(new Model.Inventory(found.InventoryId, inventory.LocationID, inventory.ProductID, found.Quantity));
 }
 public Model.Inventory ParseInventory(Entity.Inventory inventory)
 {
     return(new Model.Inventory
     {
         Id = inventory.Id,
         Quantity = inventory.Quantity,
         ProductId = inventory.ProductId,
         LocationId = inventory.LocationId
     });
 }
        public Model.Inventory UpdateInventoryItem(Model.Inventory inventory)
        {
            Entity.Inventory toUpdate = _context.Inventories
                                        .FirstOrDefault(inven => inven.Id == inventory.Id);
            toUpdate.Quantity = inventory.Quantity;

            _context.SaveChanges();
            _context.ChangeTracker.Clear();
            return(inventory);
        }
        //update inventory that already exists
        public void UpdateInventory(Inventory inventory2BUpdated)
        {
            Entity.Inventory oldInventory = _context.Inventories.Find(inventory2BUpdated.Id);
            _context.Entry(oldInventory).CurrentValues.SetValues(_mapper.ParseInventory(inventory2BUpdated));

            _context.SaveChanges();

            //This method clears the change tracker to drop all tracked entities
            _context.ChangeTracker.Clear();
        }
Example #9
0
 public Model.Inventory ParseInventory(Entity.Inventory inventory)
 {
     return(new Model.Inventory
     {
         InventoryQuantity = inventory.Quantity,
         //InventoryProduct = ParseProduct(inventory.InventoryProductNavigation),
         InventoryID = inventory.Id,
         ProductID = inventory.InventoryProduct,
         LocationID = inventory.InventoryLocation
     });
 }
 public Model.Inventory ParseInventory(Entity.Inventory inventory)
 {
     if (inventory is null)
     {
         return(null);
     }
     return(new Model.Inventory
     {
         Id = inventory.Id,
         Product = ParseProduct(inventory.Product),
         LocationId = inventory.StoreId,
         Quantity = inventory.Quantity
     });
 }
 public Model.Item GetInventory(Product product)
 {
     Entity.Inventory found = _context.Inventories.FirstOrDefault(o => o.ProductId == product.Id);
     return((found == null) ? null : new Model.Item(found.Id, found.Quantity));
 }