public Entity.Inventory ParseInventory(Model.Inventory inventory, bool create) { if (inventory is null) { return(null); } if (create) { return(new Entity.Inventory { StoreId = inventory.LocationId, ProductId = inventory.Product.Id, Quantity = inventory.Quantity }); } else { return(new Entity.Inventory { Id = inventory.Id, StoreId = inventory.LocationId, ProductId = inventory.Product.Id, Quantity = inventory.Quantity }); } }
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 Entity.Inventory ParseInventory(Model.Inventory inventory) { return(new Entity.Inventory { LocationIdentity = inventory.LocationIdentity, InventoryID = inventory.InventoryID, InventoryQuantity = inventory.InventoryQuantity }); }
public Model.Inventory AddInventory(Model.Inventory inventory) { _context.Inventories.Add( _mapper.ParseInventory(inventory, true) ); _context.SaveChanges(); _context.ChangeTracker.Clear(); return(inventory); }
public Entity.Inventory ToEntity(Model.Inventory inven) { return(new Entity.Inventory { Id = inven.Id, ProductId = inven.Product.Id, StoreId = inven.LocationId, Quantity = inven.Quantity }); }
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 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); }
public Model.Inventory AddInventory(Model.Inventory inventory, Model.Location location, Model.Product product) { _context.Inventories.Add( new Entity.Inventory { InventoryId = inventory.Id, LocationId = GetLocation(location).Id, ProductId = GetProduct(product).Id, Quantity = inventory.Quantity } ); _context.SaveChanges(); Log.Information("DL persisted inventory add to DB"); return(inventory); }
public Entity.Inventory ParseInventory(Model.Inventory inventory) { if (inventory.Id == null) { return(new Entity.Inventory { LocId = inventory.LocId }); } //For updating the superpower, you need the id to find it return(new Entity.Inventory { LocId = inventory.LocId, Id = (int)inventory.Id }); }
public Entity.Inventory ParseInventory(Model.Inventory inventory) { if (inventory.InventoryID == null) { return(new Entity.Inventory { Quantity = inventory.InventoryQuantity, //InventoryProductNavigation = ParseProduct(inventory.InventoryProduct), }); } return(new Entity.Inventory { Id = (int)inventory.InventoryID, Quantity = inventory.InventoryQuantity, InventoryLocation = (int)inventory.LocationID, InventoryProduct = (int)inventory.ProductID, //InventoryProductNavigation = ParseProduct(inventory.InventoryProduct) }); }
public Entity.Inventory ParseInventory(Model.Inventory inventory) { //when there are no inventories, NO id is set if (inventory.Id == 0) { return(new Entity.Inventory { Quantity = inventory.Quantity, ProductId = inventory.ProductId, LocationId = inventory.LocationId }); } //for updating and deleting return(new Entity.Inventory { Id = inventory.Id, Quantity = inventory.Quantity, ProductId = inventory.ProductId, LocationId = inventory.LocationId }); }
public Model.Inventory AddInventory(Model.Inventory newInventory) { _context.Inventories.Add(_mapper.ParseInventory(newInventory)); _context.SaveChanges(); return(newInventory); }