public ActionResult MakeLease(BookLeaseVM lease) { try { var bookLeaseDTO = new BookLeaseDTO { BookId = lease.BookId, Amount = lease.Amount, StudentId = lease.StudentId, GetTime = lease.GetTime, ReturnTime = lease.ReturnTime }; leaseService.MakeLease(bookLeaseDTO); return(Content("<h2>Done!</h2>")); } catch (ValidationException ex) { ModelState.AddModelError(ex.Property, ex.Message); } return(View(lease)); }
public ActionResult Lease(BookLeaseVM bookLeaseVM) { try { BookLeaseDTO bookLeaseDTO = new BookLeaseDTO { BookId = bookLeaseVM.BookId, StudentId = bookLeaseVM.StudentId, GetTime = DateTime.Now, Amount = bookLeaseVM.Amount }; if (leasesService.MakeLease(bookLeaseDTO)) { return(RedirectToAction("Index")); } return(View("Error")); } catch { return(View()); } }