public ActionResult Index(bool onlyActiveLoans) { var vm = new LoanIndexVm(); if (onlyActiveLoans) { vm.Loans = _loanService.GetAllLoans().Where(l => l.ReturnDate < l.StartDate).ToList(); vm.onlyActiveLoans = true; } else { vm.Loans = _loanService.GetAllLoans(); } foreach (var loan in vm.Loans) { var bookCopies = loan.BookCopyLoans.Where(l => l.LoanId == loan.LoanId); if (loan.ReturnDate < loan.StartDate) { loan.CalculateFee(bookCopies.Count()); _loanService.UpdateLoan(loan); } } return(View(vm)); }
//GET: loans public async Task <IActionResult> Index() { var vm = new LoanIndexVm(); vm.Loans = loanservice.GetAllLoans(); vm.CurrentDate = datetimeservice.Now; return(View(vm)); }
public IActionResult Index() { var vm = new LoanIndexVm(); vm.Loans = loanService.GetAllLoans(); vm.ReturnedLoans = loanService.GetReturnedLoans(); return(View(vm)); }
// GET: Loans public async Task <IActionResult> Index() { var loans = loanService.GetAllLoans(); var vm = new LoanIndexVm(); vm.Loans = loans; return(View(vm)); }