public ActionResult Create(int id) { PayoutViewModel payout = null; using (var unitOfWork = new UnitOfWork(new BankModuleFactory())) { var LoanAgreementService = new LoanAgreementService(unitOfWork); var agreement = LoanAgreementService.Get(a => a.Id == id, null, ag => ag.LoanAccount, ag => ag.PayoutStatus, ag => ag.LoanApplication, ag => ag.LoanApplication.Client, ag => ag.Payouts, ag => ag.Fines).FirstOrDefault(); payout = new PayoutViewModel { LoanAgreementId = agreement.Id, LoanAgreement = agreement, Currency = agreement.Currency, TotalAmount = agreement.PayoutStatus.MonthlyPayout, PrepaymentAmount = LoanAgreementService.CountPrepaymentAmount(agreement), }; } return View(payout); }