ToString() public method

public ToString ( ) : string
return string
Exemplo n.º 1
0
 public ActionResult DishDeleteConfirmed(DishModel Dish)
 {
     try
     {
         log.InfoFormat("[DishDeleteConfirmed] Dish={0} ", Dish.ToString());
         m_serviceLayer.DeleteDish(Dish);
         return RedirectToAction("DishesIndex", new { MenuPartId = Dish.MenuPartId, RestaurantId = Dish.RestaurantId });
     }
     catch(Exception ex)
     {
         log.InfoFormat("[DishDeleteConfirmed] Exception={0} ", ex.ToString());
         return View(Dish);
     }
 }
Exemplo n.º 2
0
 public ActionResult AddDish(DishModel dish)
 {
     log.InfoFormat("[AddDish] dish={0}", dish.ToString());
     int menuPartId = m_serviceLayer.GetIdByMenuPartName(dish.RestaurantId, "כל המנות");
     if (menuPartId < 0)
     {
         MenuPartModel mp = new MenuPartModel() { RestaurantId = dish.RestaurantId, Name = "כל המנות" };
         dish.MenuPartId = m_serviceLayer.AddNewMenuPartModel(mp);
     }
     else {
         dish.MenuPartId = menuPartId;
     }
     dish.Id = m_serviceLayer.AddNewDish(dish);
     return Content(dish.Id.ToString(), "text/plain");
 }
Exemplo n.º 3
0
 public ActionResult DishEdit(DishModel dish)
 {
     log.InfoFormat("[UpdateDish] dish={0}", dish.ToString());
     m_serviceLayer.UpdateDishAndCarbs(dish);
     return Content("success", "text/plain");
 }
Exemplo n.º 4
0
        public void UpdateDishAndCarbs(DishModel Dish)
        {
            log.InfoFormat("[UpdateDishAndCarbs] Dish={0} ", Dish.ToString());
            var dishModel = GetDish(Dish.MenuPartId, Dish.RestaurantId, Dish.Id);
            //SaveUserActivity(new UserActivity()
            //{
            //    Type = "UpdateDish",
            //    RestaurantID = Dish.RestaurantId,
            //    Location = Dish.ItemLocation.toLoaction(),
            //    MenuPartID = Dish.MenuPartId,
            //    DishID = Dish.Id
            //});
            if (dishModel != null &&
                dishModel.NutritionFacts.TotalCarbohydrate != Dish.NutritionFacts.TotalCarbohydrate)
            {
                Dish.State.Index += 10;
            }
            UpdateDish(Dish);

            //SaveUserActivity(new UserActivity()
            //{
            //    Type = "UpdateDish",
            //    RestaurantID = Dish.RestaurantId,
            //    Location = Dish.ItemLocation.toLoaction(),
            //    MenuPartID = Dish.MenuPartId,
            //    DishID = Dish.Id
            //});
        }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
0
 public void DeleteDish(DishModel Dish)
 {
     log.InfoFormat("[DeleteDish] Dish={0} ", Dish.ToString());
     RestaurantBasicData tempRest = GetRestaurantBasicById(Dish.RestaurantId);
     //RestaurantModel tempRest = GetRestaurantById(Dish.RestaurantId);
     tempRest.Menu.MenuParts.FirstOrDefault(mp => mp.Id == Dish.MenuPartId).Dishes.RemoveAll(dish => dish.Id == Dish.Id);
     UpdateRestaurant(tempRest);
 }
Exemplo n.º 7
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());
 }
Exemplo n.º 8
0
 public int AddNewDish(DishModel Dish)
 {
     log.InfoFormat("[AddNewDish] Dish={0} ", Dish.ToString());
     try
     {
         Dish.CreatedAt = DateTime.Now;
         Dish.UpdatedAt = DateTime.Now;
         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;
         Dish.ItemLocation = tempRest.Location;
         tempRest.Menu.MenuParts.FirstOrDefault(mp => mp.Id == Dish.MenuPartId).Dishes.Add(Dish);
         UpdateRestaurant(tempRest);
         return Dish.Id;
     }
     catch (Exception ex) {
         log.InfoFormat("[AddNewDish] Exception={0} ", ex.ToString());
         throw new ApplicationException("Problem in saving new dish, contact administraitor.");
     }
 }
Exemplo n.º 9
0
        public ActionResult DishTranslateConfirmed(DishModel Dish)
        {
            try
            {
                log.InfoFormat("[DishTranslateConfirmed] Dish={0} ", Dish.ToString());
                if (Dish != null || Dish.FromLanguage != null || Dish.ToLanguage != null)
                {
                    var transDish = m_serviceLayer.TranslateDish(Dish.RestaurantId, Dish.MenuPartId, Dish.Id, Dish.FromLanguage, Dish.ToLanguage);
                    if (transDish != null)
                    {
                        m_serviceLayer.UpdateDish(transDish, Dish.RestaurantId, Dish.MenuPartId);
                        return RedirectToAction("DishesIndex", new { MenuPartId = Dish.MenuPartId, RestaurantId = Dish.RestaurantId });
                    }
                }

                ViewBag.Message = "There is no translation on choosed language";
                return View(Dish);
            }
            catch(Exception ex)
            {
                log.InfoFormat("[DishTranslateConfirmed] Exception={0} ", ex.ToString());
                return View(Dish);
            }
        }