Esempio n. 1
0
        //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        // Manage books
        //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        public int addBook(string title, string author, string publisher)
        {
            int catNumber = 0;
            Book book = new Book
            {
                Title = title,
                Author = author,
                Publisher = publisher
            };

            db.Books.InsertOnSubmit(book);
            db.SubmitChanges(); //submit the action to customer table

            catNumber = book.CatalogueNumber;
            /*var newBook = from b in db.Books
                     where b.Title == title
                     select b.CatalogueNumber;
            foreach (var b in newBook)
            {
                catNumber = Convert.ToInt32(b);
            }*/
            return catNumber;
        }
Esempio n. 2
0
 public Book findBookByCatNum(int catnum)
 {
     Book rb = new Book();
     bool found = false;
     var books = from b in db.Books
                 where b.CatalogueNumber == catnum
                 select new
                 {
                     b.CatalogueNumber,
                     b.Author,
                     b.Title,
                     b.Publisher
                 };
     foreach (var b in books)
     {
         rb.CatalogueNumber = b.CatalogueNumber;
         rb.Author = b.Author;
         rb.Title = b.Title;
         rb.Publisher = b.Publisher;
         found = true;
     }
     if (!found) return null;
     return rb;
 }
Esempio n. 3
0
 partial void UpdateBook(Book instance);
Esempio n. 4
0
 partial void DeleteBook(Book instance);
Esempio n. 5
0
 partial void InsertBook(Book instance);