Esempio n. 1
0
        public static List<Book> GetBooks(Boolean useDB)
        {
            try
            {
                List<Book> books = new List<Book>();
                DataTable dt;
                if (useDB)
                {
                    dt = DBBooks.GetBooks(cs);
                }
                else
                {
                    dt = DBBooks.GetTestData();
                }
                Book book;
                foreach (DataRow dr in dt.Rows)
                {
                    book = new Book((int)dr["id"]);
                    book.Name = dr["name"].ToString();
                    book.Author = dr["author"].ToString();
                    book.Country = dr["country"].ToString();
                    book.Year = (int)dr["year"];
                    books.Add(book);
                }
                return books;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            

        }
Esempio n. 2
0
 public static int UpdateBook(Book book)
 {
     try
     {
         int rows = DBBooks.UpdateBook(cs, book.ID, book.Name, book.Author, book.Country, book.Year);
         return rows;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }