Exemplo n.º 1
0
        /// <summary>
        /// List all the books avaialable
        /// </summary>
        /// <returns>Return all the books available</returns>
        public List <ViewBookAvailableModel> ListBooksAvailable()
        {
            List <ViewBookAvailableModel> _books = new List <ViewBookAvailableModel>();

            _bookAvailableTable = _bookDao.GetBookAvailable();

            foreach (DataSet1.ViewBookAvailableRow booksRow in _bookAvailableTable.Rows)
            {
                ViewBookAvailableModel tempRow = ViewBookAvailableModel.Parse(booksRow);
                _books.Add(tempRow);
            }

            return(_books);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Return all registers from Book Available.
        /// </summary>
        /// <returns>List<T</returns>
        public List <ViewBookAvailableModel> GetAllAvailableBooks()
        {
            try
            {
                _listViewBooksAvailableModel = new List <ViewBookAvailableModel>();
                _viewBookAvailableDataTable  = _bookDAO.GetAllBooksAvailableView();

                foreach (BookDS.ViewBookAvailableRow row in _viewBookAvailableDataTable.Rows)
                {
                    _listViewBooksAvailableModel.Add(ViewBookAvailableModel.Parse(row));
                }

                return(_listViewBooksAvailableModel);
            }
            catch (Exception ex)
            {
                //Error log simulate
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                throw new BusinessLogicException(ex.Message);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Search availabe books using ISBN, book name and author, only book name and only author.
        /// The book name and author are searched with partialy letter, it is not mandotory
        /// to inform the exact name.
        /// </summary>
        /// <param name="bookName">string bookName</param>
        /// <param name="author">string author</param>
        /// <returns>List<ViewBookAvailableModel></returns>
        public List <ViewBookAvailableModel> GetAllBooksAvailableByBookNameAndAuthor(string bookName, string author)
        {
            try
            {
                _listViewBooksAvailableModel = new List <ViewBookAvailableModel>();

                if (bookName != "" || author != "")
                {
                    _viewBookAvailableDataTable = _bookDAO.GetAllBooksAvailableByBookNameAndAuthorView(bookName, author);
                    foreach (BookDS.ViewBookAvailableRow row in _viewBookAvailableDataTable.Rows)
                    {
                        _listViewBooksAvailableModel.Add(ViewBookAvailableModel.Parse(row));
                    }
                }
                return(_listViewBooksAvailableModel);
            }
            catch (Exception ex)
            {
                //Error log simulate
                Console.WriteLine(ex.ToString());
                Console.WriteLine(ex.GetBaseException().ToString());
                throw new BusinessLogicException(ex.Message);
            }
        }
Exemplo n.º 4
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 <ViewBookAvailableModel> SearchBooksAvailable(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 <ViewBookAvailableModel> _books = new List <ViewBookAvailableModel>();

                    _bookAvailableTable = _bookDao.GetBookAvailableByBookNameAuthorName(bookName, authorName);

                    foreach (DataSet1.ViewBookAvailableRow booksRow in _bookAvailableTable.Rows)
                    {
                        ViewBookAvailableModel tempRow = ViewBookAvailableModel.Parse(booksRow);
                        _books.Add(tempRow);
                    }

                    return(_books);
                }
                else if (categoryName != "All Categories" && authorName != "")
                {
                    //search book with bookName and authorName and categoryName
                    List <ViewBookAvailableModel> _books = new List <ViewBookAvailableModel>();

                    _bookAvailableTable = _bookDao.GetBookAvailableByBookNameAuthorNameCategoryName(bookName, authorName, categoryName);

                    foreach (DataSet1.ViewBookAvailableRow booksRow in _bookAvailableTable.Rows)
                    {
                        ViewBookAvailableModel tempRow = ViewBookAvailableModel.Parse(booksRow);
                        _books.Add(tempRow);
                    }

                    return(_books);
                }
                else if (categoryName != "All Categories" && authorName == "")
                {
                    //search book with bookName and authorName and categoryName
                    List <ViewBookAvailableModel> _books = new List <ViewBookAvailableModel>();

                    _bookAvailableTable = _bookDao.GetBookAvailableByBookNameCategoryName(bookName, categoryName);

                    foreach (DataSet1.ViewBookAvailableRow booksRow in _bookAvailableTable.Rows)
                    {
                        ViewBookAvailableModel tempRow = ViewBookAvailableModel.Parse(booksRow);
                        _books.Add(tempRow);
                    }

                    return(_books);
                }
                else
                {
                    List <ViewBookAvailableModel> _books = new List <ViewBookAvailableModel>();

                    _bookAvailableTable = _bookDao.GetBookAvailableByBookNameOnly(bookName);

                    foreach (DataSet1.ViewBookAvailableRow booksRow in _bookAvailableTable.Rows)
                    {
                        ViewBookAvailableModel tempRow = ViewBookAvailableModel.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 <ViewBookAvailableModel> _books = new List <ViewBookAvailableModel>();

                    _bookAvailableTable = _bookDao.GetBookAvailable();

                    foreach (DataSet1.ViewBookAvailableRow booksRow in _bookAvailableTable.Rows)
                    {
                        ViewBookAvailableModel tempRow = ViewBookAvailableModel.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 <ViewBookAvailableModel> _books = new List <ViewBookAvailableModel>();

                    _bookAvailableTable = _bookDao.GetBookAvailableByAuthorOnly(authorName);

                    foreach (DataSet1.ViewBookAvailableRow booksRow in _bookAvailableTable.Rows)
                    {
                        ViewBookAvailableModel tempRow = ViewBookAvailableModel.Parse(booksRow);
                        _books.Add(tempRow);
                    }

                    return(_books);
                }
                else
                {
                    List <ViewBookAvailableModel> _books = new List <ViewBookAvailableModel>();

                    _bookAvailableTable = _bookDao.GetBookAvailableByAuthor(authorName, categoryName);

                    foreach (DataSet1.ViewBookAvailableRow booksRow in _bookAvailableTable.Rows)
                    {
                        ViewBookAvailableModel tempRow = ViewBookAvailableModel.Parse(booksRow);
                        _books.Add(tempRow);
                    }

                    return(_books);
                }
            }
        }