public ActionResult LoanAgreementReject(long id) { ICollection<ValidationResult> error = new List<ValidationResult>(); LoanAgreement loanAgreement = null; try { using (var unitOfWork = new UnitOfWork(new BankModuleFactory())) { var Service = new LoanAgreementService(unitOfWork); loanAgreement = Service.Get(sr => sr.Id == id).First(); Service.RejectAgreement(loanAgreement); error = unitOfWork.Commit(); } if (error.Any()) { ModelState.AddModelError(string.Empty, error.First().ErrorMessage); return View("LoanAgreementDetails", loanAgreement); } } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); return View("LoanAgreementDetails", loanAgreement); } return RedirectToAction("AgreementList"); }