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));
        }
Exemple #2
0
        //GET: loans
        public async Task <IActionResult> Index()
        {
            var vm = new LoanIndexVm();

            vm.Loans       = loanservice.GetAllLoans();
            vm.CurrentDate = datetimeservice.Now;
            return(View(vm));
        }
Exemple #3
0
        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));
        }