Exemplo n.º 1
0
 private void AddHistory(OrderHistoryDataModel history)
 {
     if (history != null)
     {
         context.OrderHistories.Add(history);
     }
 }
Exemplo n.º 2
0
        public void UpdateStock(IEnumerable <StockDataModel> updatedStocks, int recipeId)
        {
            int locationId                = updatedStocks.FirstOrDefault().LocationId;
            var originalStock             = context.Stocks.Where(a => a.LocationId == locationId);
            OrderHistoryDataModel history = new OrderHistoryDataModel();

            if (originalStock != null && updatedStocks != null)
            {
                foreach (var updatedStock in updatedStocks)
                {
                    originalStock.Where(x => x.IngredientId == updatedStock.IngredientId).FirstOrDefault().Unit = updatedStock.Unit;
                }

                history.DateOrdered = DateTime.Now;
                history.Quantity    = 1;
                history.RecipeId    = recipeId;

                AddHistory(history);
                context.SaveChanges();
            }
        }