コード例 #1
0
 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
         });
     }
 }
コード例 #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);
 }
コード例 #3
0
 public Entity.Inventory ParseInventory(Model.Inventory inventory)
 {
     return(new Entity.Inventory
     {
         LocationIdentity = inventory.LocationIdentity,
         InventoryID = inventory.InventoryID,
         InventoryQuantity = inventory.InventoryQuantity
     });
 }
コード例 #4
0
 public Model.Inventory AddInventory(Model.Inventory inventory)
 {
     _context.Inventories.Add(
         _mapper.ParseInventory(inventory, true)
         );
     _context.SaveChanges();
     _context.ChangeTracker.Clear();
     return(inventory);
 }
コード例 #5
0
 public Entity.Inventory ToEntity(Model.Inventory inven)
 {
     return(new Entity.Inventory {
         Id = inven.Id,
         ProductId = inven.Product.Id,
         StoreId = inven.LocationId,
         Quantity = inven.Quantity
     });
 }
コード例 #6
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));
 }
コード例 #7
0
        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);
        }
コード例 #8
0
 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);
 }
コード例 #9
0
 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
     });
 }
コード例 #10
0
 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)
     });
 }
コード例 #11
0
 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
     });
 }
コード例 #12
0
 public Model.Inventory AddInventory(Model.Inventory newInventory)
 {
     _context.Inventories.Add(_mapper.ParseInventory(newInventory));
     _context.SaveChanges();
     return(newInventory);
 }