public ActionResult Delete()
        {
            var vm = new LoanDeleteVm();
            var listOfActiveLoans = _loanService.GetAllLoans().Where(l => l.ReturnDate > l.StartDate).OrderBy(l => l.LoanId);

            vm.LoanIdList = new SelectList(listOfActiveLoans, "LoanId", "LoanId");
            return(View(vm));
        }
        public ActionResult Delete(LoanDeleteVm vm)
        {
            try
            {
                // Before we delete a loan we als clean the BookCopyLoans attached to this loan ID in the db
                _bookCopyLoanService.DeleteBookCopyLoansByLoanId(vm.LoanId);
                _loanService.DeleteLoanByLoanId(vm.LoanId);

                return(RedirectToAction(nameof(Index)));
            }
            // we use general exception to also catch the null exception
            catch (Exception)
            {
                return(RedirectToAction(nameof(Delete)));
            }
        }