public ActionResult CertificateGridViewPartialAddNew([ModelBinder(typeof(DevExpressEditorsBinder))] Models.Certifications item) { if (item.PersonalInformationId > 0) { if (unitOfWork.CertificationTypesRepo.Find(m => m.Id == item.CertificationTypeId).CertificationType == "Barangay Clearance" && unitOfWork.BlottersRepo.Fetch(m => m.ViolatorId == item.PersonalInformationId).Any(m => m.IsCleared != true)) { ModelState.AddModelError("PersonalInformationId", "Citizen has a previous blotter case that is not yet cleared"); ViewData["EditError"] = "Citizen has a previous blotter case that is not yet cleared"; ViewData["model"] = item; return(PartialView("_CertificateGridViewPartial", unitOfWork.CertificationsRepo.Get())); } } if (ModelState.IsValid) { try { // Insert here a code to insert the new item in your model unitOfWork.CertificationsRepo.Insert(item); unitOfWork.Save(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; ViewData["model"] = item; } var model = unitOfWork.CertificationsRepo.Get(); return(PartialView("_CertificateGridViewPartial", model)); }
public ActionResult CertificateGridViewPartial([ModelBinder(typeof(DevExpressEditorsBinder))] Models.Certifications item) { var model = unitOfWork.CertificationsRepo.Get(); ViewData["model"] = item; if (item.PersonalInformationId > 0) { if (unitOfWork.CertificationTypesRepo.Find(m => m.Id == item.CertificationTypeId).CertificationType == "Barangay Clearance" && unitOfWork.BlottersRepo.Fetch(m => m.ViolatorId == item.PersonalInformationId).Any(m => m.IsCleared != true)) { ModelState.AddModelError("PersonalInformationId", "Citizen has a previous blotter case that is not yet cleared"); ViewData["EditError"] = "Citizen has a previous blotter case that is not yet cleared"; ViewData["model"] = item; return(PartialView("_CertificateGridViewPartial", unitOfWork.CertificationsRepo.Get())); } } return(PartialView("_CertificateGridViewPartial", model)); }
public ActionResult CertificateGridViewPartialUpdate([ModelBinder(typeof(DevExpressEditorsBinder))] Models.Certifications item) { if (ModelState.IsValid) { try { // Insert here a code to update the item in your model unitOfWork.CertificationsRepo.Update(item); unitOfWork.Save(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } var model = unitOfWork.CertificationsRepo.Get(); return(PartialView("_CertificateGridViewPartial", model)); }
public ActionResult AddEditCertification([ModelBinder(typeof(DevExpressEditorsBinder))] int?certificateId, [ModelBinder(typeof(DevExpressEditorsBinder))] Models.Certifications item) { var model = unitOfWork.CertificationsRepo.Find(m => m.Id == certificateId); return(PartialView(model)); }