public static BookToList CastBookTableToBookLIST(BooksTable bookTable) { try { BookToList book = new BookToList() { numberOfViewers = bookTable.numberOfViewers, picNAme = bookTable.picNAme, autherId = LookupBL.getLookupByCode(Constants.AutherTableName, bookTable.autherId), // categoryId = LookupBL.getLookupByCode(Constants.BooksCategoryTableName, bookTable.categoryId), id = bookTable.id, // description = bookTable.description, // numOfPages = bookTable.numOfPages, isBorrowed = bookTable.isBorrowed, // lenderId = bookTable.lenderId, nameId = LookupBL.getLookupByCode(Constants.BooksNameTableName, bookTable.nameId), // publishingId = LookupBL.getLookupByCode(Constants.PuplishingTableName, bookTable.publishingId) }; return(book); } catch (Exception) { return(null); } }
public static List <BookToList> Serch(string name, int?categoryIdSearch, string autherToSerch, string publishingToSerch, int?cityCode) { List <BooksTable> booksDB = BooksData.Serch(name, categoryIdSearch, autherToSerch, publishingToSerch, cityCode); List <BookToList> resBooks = new List <BookToList>(); foreach (var item in booksDB) { BookToList b = CastBookTableToBookLIST(item); if (b != null) { resBooks.Add(b); } } return(resBooks); }
public static List <BookToList> GetAllBook() { List <BooksTable> booksDB = BooksData.getAllBooks(); List <BookToList> resBooks = new List <BookToList>(); foreach (var item in booksDB) { BookToList b = CastBookTableToBookLIST(item); if (b != null) { resBooks.Add(b); } } return(resBooks); }