public void TestGetAllBooks() { IBookDal bookdal = new BookDal(); IList<Book> book = bookdal.GetAllBooks(); Console.Write(book[0].Author); Assert.IsNotNull(bookdal.GetAllBooks()); }
public IList<Book> GetAllBooks() { IBookDal bookdal = new BookDal(); IList<Book> books = bookdal.GetAllBooks(); if (books.Count != 0) { return books; } else { return null; } }
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; } }
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; } }
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; } }
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; } }
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; } }