示例#1
0
        public void TestGetAllBooks()
        {
            IBookDal bookdal = new BookDal();

            IList<Book> book = bookdal.GetAllBooks();
            Console.Write(book[0].Author);
            Assert.IsNotNull(bookdal.GetAllBooks());
        }
示例#2
0
        public IList<Book> GetAllBooks()
        {
            IBookDal bookdal = new BookDal();
            IList<Book> books = bookdal.GetAllBooks();

            if (books.Count != 0)
            {
                return books;
            }
            else
            {
                return null;
            }
        }
示例#3
0
        public IList<Book> BookSearch(String searchString)
        {
            try
            {
                IBookDal bookDal = new BookDal();
                IList<Book> returnedBookList = bookDal.SearchBook(searchString);
                return returnedBookList;

            }
            catch (Exception e)
            {
                Console.WriteLine("Error in BookService,BookSearch()");
                Console.Write(e.ToString());
                return null;
            }
        }
示例#4
0
        public BookRequest GetByBook(int bookid)
        {
            try
            {
                IBookDal bookDal = new BookDal();
                Book book = bookDal.GetById(bookid);

                IBookRequestDal bookRequestDal = new BookRequestDal();
                BookRequest bookRequest = bookRequestDal.GetByBook(book);

                return bookRequest;
            }

            catch (Exception e)
            {
                Console.WriteLine("Error in BookRequestService , GetBookById()");
                Console.Write(e.ToString());
                return null;
            }
        }
示例#5
0
        public Book GetById(int id)
        {
            try
            {
                IBookDal bookdal = new BookDal();
                Book book = bookdal.GetById(id);

                if (book!= null)
                {
                    return book;
                }
                return null;
            }

            catch (Exception e)
            {
                Console.WriteLine("Error in BookService,getbyId");
                Console.Write(e.ToString());
                return null;
            }
        }
示例#6
0
        public Boolean BookRequest(Book book, User user)
        {
            try
            {
                IList<User> users = new List<User>();
                users.Add(user);
               //             book.Users = users;

                IList<Book> books = new List<Book>();
                books.Add(book);

                IBookDal bookdal = new BookDal();
                Boolean status = bookdal.SaveBooks(books);

                return status;
            }

            catch (Exception e)
            {
                Console.WriteLine("Some sort of error in BookService, BookRequest()");
                Console.WriteLine(e.ToString());
                return false;
            }
        }
示例#7
0
        public bool SaveBooks(Book book)
        {
            try
            {
                IBookDal bookdal = new BookDal();
                IList<Book> books = new List<Book>();
                books.Add(book);
                Boolean status = bookdal.SaveBooks(books);
                return status;
            }

            catch (Exception e)
            {
                Console.WriteLine("Book service crashed");
                Console.Write(e.ToString());
                return false;
            }
        }