public ActionResult StudentGridViewPartialAddNew([ModelBinder(typeof(DevExpressEditorsBinder))] MurongEnrollment.Models.Students item, string SectionId) { if (ModelState.IsValid) { try { item.Id = Guid.NewGuid().ToString(); /* item.Enrollments.Add(new Models.Enrollments() * { * * });*/ //item.Enrollments.Id = Guid.NewGuid().ToString(); //item.Enrollments.Sections = unitOfWork.SectionRepo.Find(m => m.Id == SectionId); unitOfWork.StudentRepo.Insert(item); unitOfWork.Save(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } var model = unitOfWork.StudentRepo.Get(includeProperties: "Enrollments,Enrollments.Sections,Enrollments.Sections.GradeLevels"); return(PartialView("_StudentGridViewPartial", model)); }
public ActionResult StudentGridViewPartialUpdate([ModelBinder(typeof(DevExpressEditorsBinder))] MurongEnrollment.Models.Students item) { var model = new object[0]; if (ModelState.IsValid) { try { // Insert here a code to update the item in your model } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_StudentGridViewPartial", model)); }
public ActionResult StudentGridViewPartialUpdate([ModelBinder(typeof(DevExpressEditorsBinder))] MurongEnrollment.Models.Students item, string SectionId) { if (ModelState.IsValid) { try { unitOfWork.StudentRepo.Update(item); unitOfWork.Save(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } var model = unitOfWork.StudentRepo.Get(includeProperties: "Enrollments,Enrollments.Sections,Enrollments.Sections.GradeLevels"); return(PartialView("_StudentGridViewPartial", model)); }