예제 #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);
        }
예제 #2
0
 /// <summary>
 /// Parse of data from the DS object to the model object.
 /// Returns null if the row is null.
 /// </summary>
 /// <param name="row">BookDS.ViewBookAvailableRow row</param>
 /// <returns>ViewBookAvailableModel</returns>
 public static ViewBookAvailableModel Parse(BookDS.ViewBookAvailableRow row)
 {
     if (row == null)
     {
         return(null);
     }
     else
     {
         ViewBookAvailableModel viewBookAvailableModel = new ViewBookAvailableModel();
         viewBookAvailableModel._bookAvailableISBN         = row.ISBN;
         viewBookAvailableModel._bookAvailableName         = row.BookName;
         viewBookAvailableModel._bookAvailablePublisher    = row.Publisher;
         viewBookAvailableModel._bookAvailablePublishYear  = row.PublishYear;
         viewBookAvailableModel._bookAvailablePages        = row.Pages;
         viewBookAvailableModel._bookAvailableAuthorName   = row.AuthorName;
         viewBookAvailableModel._bookAvailableCategoryName = row.CategoryName;
         viewBookAvailableModel._bookAvailableLanguageName = row.LanguageName;
         return(viewBookAvailableModel);
     }
 }
        // Get the value from the dataset and stock them in viewBook
        public static ViewBookAvailableModel Parse(DataSet1.ViewBookAvailableRow BooksRow)
        {
            if (BooksRow == null)
            {
                return(null);
            }
            else
            {
                ViewBookAvailableModel viewBook = new ViewBookAvailableModel();
                viewBook.Isbn          = BooksRow.ISBN;
                viewBook.Publisher     = BooksRow.Publisher;
                viewBook.BookName      = BooksRow.BookName;
                viewBook.PublisherYear = BooksRow.PublishYear;
                viewBook.Pages         = BooksRow.Pages;
                viewBook.AuthorName    = BooksRow.AuthorName;
                viewBook.CategoryName  = BooksRow.CategoryName;
                viewBook.LanguageName  = BooksRow.LanguageName;

                return(viewBook);
            }
        }
예제 #4
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);
            }
        }
예제 #5
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);
            }
        }
예제 #6
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);
                }
            }
        }