Example #1
0
 public int AddNewDish(DishModel dish)
 {
     log.InfoFormat("[AddNewDish] Dish={0} ", dish.ToString());
     try
     {
         RestaurantModel tempRest = GetRestaurantById(dish.RestaurantId);
         if (tempRest.Menu.MenuParts.FirstOrDefault(mp => mp.Id == dish.MenuPartId).Dishes.Count > 0)
             dish.Id = tempRest.Menu.MenuParts.FirstOrDefault(mp => mp.Id == dish.MenuPartId).Dishes.Max(c => c.Id) + 1;
     }
     catch (Exception ex)
     {
         log.ErrorFormat("[AddNewDish] Exception={0}, DishModel={1}", ex.ToString(), dish);
         throw new ApplicationException("Problem in saving new dish, contact administraitor.");
     }
     return AddNewDishBasic(dish.RestaurantId, dish.MenuPartId, dish.ToDish());
 }
Example #2
0
 public void UpdateDish(DishModel dishModel)
 {
     log.InfoFormat("[UpdateDish] dishModel={0}.", dishModel.ToString());
     RestaurantBasicData rest = GetRestaurantBasicById(dishModel.RestaurantId);
     Dish dbDish = rest.Menu.MenuParts.FirstOrDefault(mp => mp.Id == dishModel.MenuPartId).Dishes.First(dish => dish.Id == dishModel.Id);
     dishModel.UpdatedAt = DateTime.Now;
     if (dbDish.BaseLineNutritionFacts == null && dbDish.NutritionFacts != null)
     {
         dbDish.BaseLineNutritionFacts = dbDish.NutritionFacts;
     }
     dishModel.ToDish(dbDish);
     UpdateRestaurant(rest);
 }
Example #3
0
 //public void UpdateDish(DishModel dish)
 //{
 //    log.InfoFormat("[UpdateDish] dish={0} ", dish.ToString());
 //    RestaurantModel rest = GetRestaurantById(dish.RestaurantId);
 //    DeleteDish(dish);               //remove old Dish from Dishes List
 //    dish.UpdatedAt = DateTime.Now;
 //    RestaurantModel tempRest = GetRestaurantById(dish.RestaurantId);
 //    dish.ItemLocation = tempRest.Location;
 //    tempRest.Menu.MenuParts.FirstOrDefault(mp => mp.Id == dish.MenuPartId).Dishes.Add(dish);      //add new Dish to Dishes List
 //    UpdateRestaurant(tempRest);
 //}
 public void UpdateDish(DishModel dishModel)
 {
     RestaurantBasicData rest = GetRestaurantBasicById(dishModel.RestaurantId);
     Dish dbDish = rest.Menu.MenuParts.FirstOrDefault(mp => mp.Id == dishModel.MenuPartId).Dishes.First(dish => dish.Id == dishModel.Id);
     dishModel.UpdatedAt = DateTime.Now;
     dishModel.ToDish(dbDish);
     UpdateRestaurant(rest);
 }