public ActionResult AddLoan(int clientId) { LibraryDal dal = new LibraryDal(); AddLoanViewModel model = new AddLoanViewModel(); Client client = dal.GetClientById(clientId); model.loan = new ClientBook(); model.loan.ClientId = clientId; model.loan.LoanDuration = client.Category.LoanDuration; return(View(model)); }
public ActionResult AddLoan(AddLoanViewModel model) { LibraryDal dal = new LibraryDal(); Book book = dal.GetBookByISBN(model.ISBN); if (book != null) { model.bookFound = true; model.loan.BookId = book.Id; dal.AddLoan(model.loan); return(RedirectToAction("Index")); } else { model.bookFound = false; } return(View(model)); }