public ActionResult SchoolYearPartialAddNew([ModelBinder(typeof(DevExpressEditorsBinder))] MurongEnrollment.Models.SchoolYears item) { if (ModelState.IsValid) { try { // Insert here a code to insert the new item in your model unitOfWork.SchoolYearRepo.Get().ToList().ForEach(x => x.isActive = false); item.Id = Guid.NewGuid().ToString(); item.isActive = true; unitOfWork.SchoolYearRepo.Insert(item); unitOfWork.Save(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } var model = unitOfWork.SchoolYearRepo.Get(); return(PartialView("_SchoolYearPartial", model)); }
public ActionResult SchoolYearPartialDelete([ModelBinder(typeof(DevExpressEditorsBinder))] MurongEnrollment.Models.SchoolYears item) { if (item != null) { try { unitOfWork.SchoolYearRepo.Delete(unitOfWork.SchoolYearRepo.Find(m => m.Id == item.Id)); unitOfWork.Save(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } var model = unitOfWork.SchoolYearRepo.Get(); return(PartialView("_SchoolYearPartial", model)); }
public ActionResult SchoolYearPartialUpdate([ModelBinder(typeof(DevExpressEditorsBinder))] MurongEnrollment.Models.SchoolYears item) { if (ModelState.IsValid) { try { unitOfWork.SchoolYearRepo.Insert(item); unitOfWork.Save(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } var model = unitOfWork.SchoolYearRepo.Get(); return(PartialView("_SchoolYearPartial", model)); }