public async Task <IActionResult> UpdateLoanStatus(ReturnLoanVm vm) { if (ModelState.IsValid) { var updatedLoan = new Loan(); updatedLoan.Id = vm.Id; updatedLoan.MemberId = vm.MemberId; updatedLoan.bookCopyId = vm.BookCopyId; updatedLoan.LoanDate = vm.LoanDate; updatedLoan.Returned = true; updatedLoan.ReturnDate = datetimeservice.Now; loanservice.UpdateLoan(updatedLoan); return(RedirectToAction(nameof(Index))); } return(RedirectToAction("Error", "Home", "")); }
public async Task <IActionResult> UpdateLoanStatus(int id)/*int? id*/ { if (ModelState.IsValid) { var vm = new ReturnLoanVm(); var loan = loanservice.GetLoan(id); vm.member = loan.member; vm.bookCopy = loan.bookCopy; vm.LoanDate = loan.LoanDate; vm.ReturnDate = loan.ReturnDate; vm.MemberId = vm.MemberId; vm.BookCopyId = vm.BookCopyId; vm.CurrentDate = datetimeservice.Now; vm.Id = loan.Id; return(View(vm)); } return(RedirectToAction("Error", "Home", "")); }