public ActionResult PopulateFoods(int id, int page = 1) { string result = _appService.GetBenefitByIdWithFoods(id); BenefitVm benefit = string.IsNullOrEmpty(result) ? new BenefitVm() : JsonConvert.DeserializeObject <BenefitVm>(result); IPagedList <FoodVm> foodList = benefit.Foods.ToPagedList(page, 20); return(PartialView("_FoodTable", foodList)); }
public ActionResult Details(int id) { string result = id == 0 ? string.Empty : _appService.GetById(id); BenefitVm benefit = string.IsNullOrEmpty(result)? null : JsonConvert.DeserializeObject <BenefitVm>(result); if (benefit == null) { return(RedirectToAction("Index")); } return(View(benefit)); }
public ActionResult Create(BenefitVm benefit) { try { if (!ModelState.IsValid) { return(View(benefit)); } string data = JsonHelper <BenefitVm> .Serialize(benefit); _appService.Add(data); return(RedirectToAction("Index")); } catch (Exception ex) { return(View(benefit)); } }