public int GetAvailableStock(DateTime date, int catalogItemId)
        {
            CatalogItemsStock s = ents.CatalogItemsStocks.Where(x => x.CatalogItemId == catalogItemId).ToList().Where(y => y.Date.Date == date.Date).FirstOrDefault();

            if (s != null)
            {
                return(s.AvailableStock);
            }
            else
            {
                return(0);
            }
        }
        public void CreateAvailableStock(CatalogItemsStock cat)
        {
            CatalogItemsStock s = catalogItemsStock.Where(x => x.CatalogItemId == cat.CatalogItemId).ToList()
                                  .Where(y => y.Date.Date == cat.Date.Date).FirstOrDefault();

            /* Overwrite the existing stock item for that date if we already have one for this item. Otherwise, make a new entry*/
            if (s != null)
            {
                s.AvailableStock = cat.AvailableStock;
            }
            else
            {
                var maxId = catalogItemsStock.Max(i => i.StockId);
                cat.StockId = ++maxId;
                catalogItemsStock.Add(cat);
            }
        }
        public void CreateAvailableStock(CatalogItemsStock catalogItemsStock)
        {
            CatalogItemsStock s = ents.CatalogItemsStocks.Where(x => x.CatalogItemId == catalogItemsStock.CatalogItemId).ToList()
                                  .Where(y => y.Date.Date == catalogItemsStock.Date.Date).FirstOrDefault();

            /* Overwrite the existing stock item for that date if we already have one for this item. Otherwise, make a new entry*/
            if (s != null)
            {
                s.AvailableStock    = catalogItemsStock.AvailableStock;
                ents.Entry(s).State = EntityState.Modified;
                ents.SaveChanges();
            }
            else
            {
                var maxId = ents.CatalogItemsStocks.Max(i => i.StockId);
                catalogItemsStock.StockId = ++maxId;
                ents.CatalogItemsStocks.Add(catalogItemsStock);
                ents.SaveChanges();
            }
        }
Пример #4
0
 public void CreateAvailableStock(CatalogItemsStock catalogItemsStock)
 {
     throw new NotImplementedException();
 }