public bool borrowBook(int bookId) { Book book = new BooksController().getBookByIdDB(bookId); if (book.copies <= 0) { return false; } book.copies--; return (new BooksController()).updateBook(book); }
public JsonResult returnBorrow(int borrowSeq) { string message = ""; try { Borrow borrow = getBorrowById(borrowSeq); borrow.ReturnDate = DateTime.Today; Book book = new BooksController().getBookByIdDB(borrow.bookId); returnBook(book); updateBorrow(borrow); } catch { message = "there's a problem.... try again later"; } return (Json(message, JsonRequestBehavior.AllowGet)); }