예제 #1
0
 private void AddHistory(OrderHistoryDataModel history)
 {
     if (history != null)
     {
         context.OrderHistories.Add(history);
     }
 }
예제 #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();
            }
        }