Esempio n. 1
0
        public BookService()
        {
            bookList = new List <BookEntity>();
            BookEntity book = new BookEntity();

            book.BookID      = 1;
            book.BookName    = "大话设计模式";
            book.BookPrice   = (decimal)45.2;
            book.BookPublish = "中国邮电出版社";
            bookList.Add(book);

            BookEntity book1 = new BookEntity();

            book1.BookID      = 2;
            book1.BookName    = "测试用例";
            book1.BookPrice   = (decimal)21.0;
            book1.BookPublish = "清华大学出版社";
            bookList.Add(book1);

            BookEntity book2 = new BookEntity();

            book2.BookID      = 3;
            book2.BookName    = "Rework";
            book2.BookPrice   = (decimal)15.4;
            book2.BookPublish = "Wrox pulishment";
            bookList.Add(book2);
        }
Esempio n. 2
0
        public bool Update(BookEntity book)
        {
            BookEntity query = (from p in bookList where p.BookID == book.BookID select p).FirstOrDefault();

            bookList.Remove(query);
            bookList.Add(book);
            return(true);
        }
Esempio n. 3
0
        public bool Delete(BookEntity book)
        {
            BookEntity bookCurrent = (from p in bookList where p.BookID == book.BookID select p).FirstOrDefault();

            return(bookList.Remove(bookCurrent));
        }
Esempio n. 4
0
 public bool Add(BookEntity book)
 {
     bookList.Add(book);
     return(true);
 }