예제 #1
0
        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());
        }
예제 #2
0
        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();
        }
예제 #3
0
        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();
        }
예제 #4
0
        public List <string> GetAllTitles()
        {
            var context = new NichiInDatabaseEntities();

            return(context.BookTables.Select((b) => b.Title).ToList());
        }