public static bool DeleteBook(Book book) { try { int c = DBBookShop.DeleteBook(cs, book.ID); return(c > 0); } catch (Exception) { throw; } }
public static int UpdateBook(Book book) { try { int c = DBBookShop.UpdateBook(cs, book.ID, book.Name, book.Author, book.Country, book.Year); return(c); } catch (Exception) { throw; } }
public static bool InsertBook(Book book) { try { int c = DBBookShop.InsertBook(cs, book.Name, book.Author, book.Country, book.Year); return(c > 0); } catch (Exception) { throw; } }
public static List <Book> GetBooks(bool useDB) { try { DataTable dt; List <Book> books = new List <Book>(); if (useDB) { dt = DBBookShop.GetBooks(cs); } else { dt = DBBookShop.GetTestData(); } // ORM = Muutetaan datatablen rivit olioiksi Book book; foreach (DataRow row in dt.Rows) { book = new Book((int)row[0]); book.Name = row[1].ToString(); book.Author = row[2].ToString(); book.Country = row[3].ToString(); book.Year = (int)row[4]; books.Add(book); } // Palautus return(books); } catch (Exception ex) { throw ex; } }