public List <Book> FindBooks(string title) { var context = new NichiInDatabaseEntities(); return(context.BookTables.Select((b) => new Book { BookID = b.BookId, Title = b.Title, Price = Convert.ToDouble(b.Cost) }).ToList()); }
public void UpdateBook(Book book) { var context = new NichiInDatabaseEntities(); var bk = context.BookTables.FirstOrDefault((b) => b.BookId == book.BookID); bk.BookId = book.BookID; bk.Cost = Convert.ToDecimal(book.Price); bk.Title = book.Title; context.SaveChanges(); }
public void AddNewBook(Book book) { var context = new NichiInDatabaseEntities(); var bookTbl = new BookTable { BookId = book.BookID, Cost = Convert.ToDecimal(book.Price), Title = book.Title }; context.BookTables.Add(bookTbl); context.SaveChanges(); }
public List <string> GetAllTitles() { var context = new NichiInDatabaseEntities(); return(context.BookTables.Select((b) => b.Title).ToList()); }