예제 #1
0
        public bool EditInventory(Domain.Models.InventoryEntry inventoryEntry)
        {
            var dbInventoryEntry = _context.InventoryEntries.FirstOrDefault(i => i.StoreId == inventoryEntry.StoreId && i.Sku == inventoryEntry.SKU);

            if (dbInventoryEntry == null)
            {
                return(false);
            }

            dbInventoryEntry.StoreId     = inventoryEntry.StoreId;
            dbInventoryEntry.Sku         = inventoryEntry.SKU;
            dbInventoryEntry.Name        = inventoryEntry.Name;
            dbInventoryEntry.Description = inventoryEntry.Description;
            dbInventoryEntry.Price       = inventoryEntry.Price;
            dbInventoryEntry.Stock       = inventoryEntry.Stock;

            _context.SaveChanges();

            return(true);
        }
예제 #2
0
        public Domain.Models.InventoryEntry GetProductByStore(int storeId, string sku)
        {
            var dbInventoryEntry = _context.InventoryEntries
                                   .FirstOrDefault(i => i.StoreId == storeId && i.Sku == sku);

            if (dbInventoryEntry == null)
            {
                return(null);
            }

            Domain.Models.InventoryEntry inventoryEntry = new Domain.Models.InventoryEntry
            {
                StoreId     = dbInventoryEntry.StoreId,
                SKU         = dbInventoryEntry.Sku,
                Name        = dbInventoryEntry.Name,
                Description = dbInventoryEntry.Description,
                Price       = dbInventoryEntry.Price,
                Stock       = dbInventoryEntry.Stock
            };

            return(inventoryEntry);
        }
예제 #3
0
        public bool AddToInventory(Domain.Models.InventoryEntry inventoryEntry)
        {
            var dbInventoryEntry = _context.InventoryEntries.FirstOrDefault(i => i.StoreId == inventoryEntry.StoreId && i.Sku == inventoryEntry.SKU);

            if (dbInventoryEntry != null)
            {
                return(false);
            }

            dbInventoryEntry = new InventoryEntry
            {
                StoreId     = inventoryEntry.StoreId,
                Sku         = inventoryEntry.SKU,
                Name        = inventoryEntry.Name,
                Description = inventoryEntry.Description,
                Price       = inventoryEntry.Price,
                Stock       = inventoryEntry.Stock
            };

            _context.InventoryEntries.Add(dbInventoryEntry);
            _context.SaveChanges();

            return(true);
        }