public ActionResult PaymentGridViewPartialUpdate([ModelBinder(typeof(DevExpressEditorsBinder))] MurongEnrollment.Models.Payments item) { if (ModelState.IsValid) { try { //if (item.PaymentAmount > unitOfWork.EnrollmentsRepo.Find(x => x.Id == item.EnrollmentId).TotalBalance) //{ // ViewData["EditError"] = "Payment should not exceed the total balance"; //} //else //{ // unitOfWork.PaymentsRepo.Update(item); // unitOfWork.Save(); //} unitOfWork.PaymentsRepo.Update(item); unitOfWork.Save(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } var model = unitOfWork.PaymentsRepo.Get(m => m.EnrollmentId == item.EnrollmentId, includeProperties: "Enrollments,Enrollments.SchoolYears"); return(PartialView("_PaymentGridViewPartial", model)); }
public ActionResult PaymentGridViewPartialDelete([ModelBinder(typeof(DevExpressEditorsBinder))] MurongEnrollment.Models.Payments item) { if (item != null) { try { unitOfWork.PaymentsRepo.Delete(unitOfWork.PaymentsRepo.Find(m => m.Id == item.Id)); unitOfWork.Save(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } var model = unitOfWork.PaymentsRepo.Get(m => m.EnrollmentId == item.EnrollmentId, includeProperties: "Enrollments,Enrollments.SchoolYears"); return(PartialView("_PaymentGridViewPartial", model)); }