public ActionResult LoanAgreementApprove(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, null, agr => agr.LoanApplication.Status).First(); Service.ApproveAgreement(loanAgreement, DateTime.Now); 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); } if (loanAgreement.LoanApplication.Status.Stage == ApplicationConsiderationStages.SuretyAgreementQueue) return RedirectToAction("SuretyAgreementDetails", new { id = loanAgreement.LoanApplicationId }); if (loanAgreement.LoanApplication.Status.Stage == ApplicationConsiderationStages.BailAgreementQueue) return RedirectToAction("BailAgreementDetails", new { id = loanAgreement.LoanApplicationId }); return View(); }