public BookLogic() { _bookDao = new BookDAO(); _bookTable = new DataSet1.ViewBookDataTable(); _categorytable = new DataSet1.TabCategoryDataTable(); _bookAvailableTable = new DataSet1.ViewBookAvailableDataTable(); _authorTable = new DataSet1.TabAuthorDataTable(); _languageTable = new DataSet1.TabLanguageDataTable(); _borrowTable = new DataSet1.ViewBookBorrowedDataTable(); _tabBookTable = new DataSet1.TabBookDataTable(); _tabReservedTable = new DataSet1.TabReservedDataTable(); _tableBorrowedTable = new DataSet1.TabBorrowDataTable(); }
/// <summary> /// Get all the Books /// </summary> /// <returns>Return list of all the book in tabBook</returns> public List <ViewBookModel> ListBooks() { List <ViewBookModel> _books = new List <ViewBookModel>(); _bookTable = _bookDao.GetBook(); foreach (DataSet1.ViewBookRow booksRow in _bookTable.Rows) { ViewBookModel tempRow = ViewBookModel.Parse(booksRow); _books.Add(tempRow); } return(_books); }
//Get book info from ViewBook with ISBN public List <ViewBookModel> GetBookInfo(string ISBN) { List <ViewBookModel> _books = new List <ViewBookModel>(); _bookTable = _bookDao.GetBookByISBN(ISBN); foreach (DataSet1.ViewBookRow booksRow in _bookTable.Rows) { ViewBookModel tempRow = ViewBookModel.Parse(booksRow); _books.Add(tempRow); } return(_books); }
/// <summary> /// Get book information /// </summary> /// <param name="ISBN">string</param> /// <returns></returns> public static ViewBookModel GetBookByISBN(string ISBN) { List <ViewBookModel> _books = new List <ViewBookModel>(); BookDAO _bookDao = new BookDAO(); DataSet1.ViewBookDataTable _borrowTable = _bookDao.GetBookByISBN(ISBN); foreach (DataSet1.ViewBookRow bookRows in _borrowTable.Rows) { ViewBookModel tempRow = ViewBookModel.Parse(bookRows); _books.Add(tempRow); } return(_books[0]); }
/// <summary> /// Search Books by authorName and categoryName /// </summary> /// <param name="authorName">Name of the author (string)</param> /// <param name="categoryName">Name of the Category</param> /// <returns>Return list of books according to the value passed</returns> public List <ViewBookModel> SearchBooks(string authorName, string categoryName, string bookName) { //if user enter book name if (bookName != "") { if (categoryName == "All Categories" && authorName != "") { //search book with bookName and authorName in all categories List <ViewBookModel> _books = new List <ViewBookModel>(); _bookTable = _bookDao.GetBookByBookNameAuthorName(bookName, authorName); foreach (DataSet1.ViewBookRow booksRow in _bookTable.Rows) { ViewBookModel tempRow = ViewBookModel.Parse(booksRow); _books.Add(tempRow); } return(_books); } else if (categoryName != "All Categories" && authorName != "") { //search book with bookName and authorName and categoryName List <ViewBookModel> _books = new List <ViewBookModel>(); _bookTable = _bookDao.GetBookByBookNameAuthorNameCategoryName(bookName, authorName, categoryName); foreach (DataSet1.ViewBookRow booksRow in _bookTable.Rows) { ViewBookModel tempRow = ViewBookModel.Parse(booksRow); _books.Add(tempRow); } return(_books); } else if (categoryName != "All Categories" && authorName == "") { //search book with bookName and authorName and categoryName List <ViewBookModel> _books = new List <ViewBookModel>(); _bookTable = _bookDao.GetBookByBookNameCategoryName(bookName, categoryName); foreach (DataSet1.ViewBookRow booksRow in _bookTable.Rows) { ViewBookModel tempRow = ViewBookModel.Parse(booksRow); _books.Add(tempRow); } return(_books); } else { List <ViewBookModel> _books = new List <ViewBookModel>(); _bookTable = _bookDao.GetBookByBookNameOnly(bookName); foreach (DataSet1.ViewBookRow booksRow in _bookTable.Rows) { ViewBookModel tempRow = ViewBookModel.Parse(booksRow); _books.Add(tempRow); } return(_books); } } else { // if all categories and no author we display all the books if (categoryName == "All Categories" && authorName == "") { List <ViewBookModel> _books = new List <ViewBookModel>(); _bookTable = _bookDao.GetBook(); foreach (DataSet1.ViewBookRow booksRow in _bookTable.Rows) { ViewBookModel tempRow = ViewBookModel.Parse(booksRow); _books.Add(tempRow); } return(_books); } // If the user select all categories we use only one parameter else if (categoryName == "All Categories" && authorName != "") { List <ViewBookModel> _books = new List <ViewBookModel>(); _bookTable = _bookDao.GetBookByAuthorOnly(authorName); foreach (DataSet1.ViewBookRow booksRow in _bookTable.Rows) { ViewBookModel tempRow = ViewBookModel.Parse(booksRow); _books.Add(tempRow); } return(_books); } else { List <ViewBookModel> _books = new List <ViewBookModel>(); _bookTable = _bookDao.GetBookByAuthor(authorName, categoryName); foreach (DataSet1.ViewBookRow booksRow in _bookTable.Rows) { ViewBookModel tempRow = ViewBookModel.Parse(booksRow); _books.Add(tempRow); } return(_books); } } }