public ActionResult AddFoodStage(int id)
        {
            IEnumerable <string> initialValues = _foodStageAppService.GetDistinctInitial();

            ViewBag.Initials = new SelectList(initialValues);

            IEnumerable <string> finalValues = _foodStageAppService.GetDistinctFinal();

            ViewBag.Finals = new SelectList(finalValues);

            FoodStageVm foodStage = new FoodStageVm {
                FoodId = id
            };

            return(PartialView("_FoodStageMgm", foodStage));
        }
        public ActionResult EditFoodStage(FoodStageVm foodStage)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    PartialView("_FoodStageEdit", foodStage);
                }

                string data = JsonHelper <FoodStageVm> .Serialize(foodStage);

                _foodStageAppService.Update(data);

                return(Json(true));
            }
            catch (Exception ex)
            {
                return(PartialView("_FoodStageEdit", foodStage));
            }
        }
        public ActionResult AddFoodStage(FoodStageVm foodStage)
        {
            bool result = false;

            try
            {
                FoodVm food = new FoodVm {
                    FoodId = foodStage.FoodId
                };
                food.FoodStages.Add(foodStage);

                string data = JsonHelper <FoodVm> .Serialize(food);

                _foodAppService.AddRelations(data);

                result = true;
            }
            catch (Exception ex)
            {
            }
            return(Json(result));
        }
        public ActionResult EditFoodStage(int id)
        {
            IEnumerable <string> initialValues = _foodStageAppService.GetDistinctInitial();

            ViewBag.Initials = new SelectList(initialValues);

            IEnumerable <string> finalValues = _foodStageAppService.GetDistinctFinal();

            ViewBag.Finals = new SelectList(finalValues);

            string      result    = id == 0 ? string.Empty : _foodStageAppService.GetById(id);
            FoodStageVm foodStage = string.IsNullOrEmpty(result)
                ? new FoodStageVm {
                FoodId = id
            }
                : JsonConvert.DeserializeObject <FoodStageVm>(result);

            if (foodStage == null)
            {
                return(RedirectToAction("Index"));
            }

            return(PartialView("_FoodStageEdit", foodStage));
        }