public ActionResult ReturnBook(string borrowerId, string bookIsbn) { // Check and see if overdue var checkOverdue = Overdue.Details(_context, borrowerId, bookIsbn); // Get borrowers details var borrow = _context.Borrows.Single(b => b.BorrowerId == borrowerId && b.Isbn == bookIsbn); if (checkOverdue.IsOverdue) { var overdue = new OverdueViewModel { Borrow = borrow, OverdueDetails = checkOverdue }; return(View("ReturnBook", overdue)); } // Set the return date and flag the book as returned. borrow.ReturnDate = DateTime.Now; borrow.IsReturned = true; var book = _context.Books.Single(b => b.Isbn == bookIsbn); // Add the number of books in stock. book.NumberInStock++; _context.SaveChanges(); // Initialize the Lending List var processBorrowers = new ProcessLendingViewModel(_context); ViewBag.Borrowers = _context.Borrows.Where(b => b.IsReturned == false).ToList().Count(); return(View("Index", processBorrowers.GetLendingDetails())); }