コード例 #1
0
        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));
        }
コード例 #2
0
        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));
            }
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }