public ActionResult SearchLoans(LoanTypeLoanCompanyViewModel search) { var Amount = search.LoanFormDto.Amount; var Interest = search.LoanFormDto.InterestRate; var Duration = search.LoanFormDto.Duration; var freq = search.LoanFormDto.RepaymentFrequency; var LType = search.LoanFormDto.LoanId; var ratings = search.LoanFormDto.Rating; Session["searchAmount"] = search.LoanFormDto.Amount; Session["searchDuration"] = search.LoanFormDto.Duration; Session["loantype"] = search.LoanFormDto.Loan; var results = (from LoanCompany in _context.LoanCompanies where (LoanCompany.MaxAmount >= Amount && LoanCompany.MinAmount <= Amount && LoanCompany.InterestRate >= Interest && LoanCompany.MaxDuration >= Duration ) from LoanType in LoanCompany.LoanTypes where (LoanType.Id == LType) select LoanCompany).OrderBy(x => x.InterestRate).ToList(); //var LoanCompanyDto = new List<LoanCompanyViewModel>(); var LoanCompanyDto = new FormCompanyViewModel(); LoanCompanyDto.LoanCompanyViewModels = new List <LoanCompanyViewModel>(); var loanTypeString = new List <string>(); foreach (var result in results) { LoanCompanyDto.LoanCompanyViewModels.Add(new LoanCompanyViewModel { Id = result.Id, Catch = result.Catch, ComparisonRate = result.ComparisonRate, ImagePath = result.ImagePath, InterestRate = result.InterestRate, MaxAmount = result.MaxAmount, MaxDuration = result.MaxDuration, MinAmount = result.MinAmount, Name = result.Name, Rating = result.Rating, MonthlyRepayment = GetMonthly((long)Amount, result.InterestRate, (int)Duration), RepaymentFrequency = result.RepaymentFrequency }); } ViewBag.duration = Duration; ViewBag.loanTitle = search.LoanFormDto.Loan; ViewBag.Money = Amount; ViewBag.Id = LType; return(View(LoanCompanyDto)); }
public ActionResult LoanForm(int Id) { var loanType = _context.LoanTypes.SingleOrDefault(c => c.Id == Id); var TypeCompany = new LoanTypeLoanCompanyViewModel { LoanType = loanType, LoanFormDto = new LoanFormDto() }; return(PartialView("_LoanForm", TypeCompany)); }