Esempio n. 1
0
        private static Book AddBook(string title, string description, DateTime datePublished, int pages, string isbn, int bookCopies)
        {
            using (BookDBDataContext context = new BookDBDataContext())
            {
                Book newBook = new Book()
                {
                    Title = title,
                    BookResume = description,
                    DatePublished = datePublished,
                    Pages = pages,
                    ISBN = isbn
                };

                context.Books.InsertOnSubmit(newBook);

                while (bookCopies > 0)
                {
                    var bookCopy = new BookCopy()
                    {
                        Book = newBook
                    };
                    context.BookCopies.InsertOnSubmit(bookCopy);
                    bookCopies--;
                }

                //var existing = context.Authors.FirstOrDefault(a => a.FirstName.Contains("G"));

                //if (existing != null)
                //{
                //    var bookAuthor = new BookAuthor()
                //    {
                //        BookID = newBook.ID,
                //        AuthorID = existing.ID
                //    };
                //}

                //var bookGenre = new BookGenre()
                //{
                //    BookID = newBook.ID
                //};

                context.SubmitChanges();
                return newBook;
            }
        }
Esempio n. 2
0
 partial void DeleteBookCopy(BookCopy instance);
Esempio n. 3
0
 partial void UpdateBookCopy(BookCopy instance);
Esempio n. 4
0
 partial void InsertBookCopy(BookCopy instance);
Esempio n. 5
0
		private void detach_BookCopies(BookCopy entity)
		{
			this.SendPropertyChanging();
			entity.Book = null;
		}
Esempio n. 6
0
		private void attach_BookCopies(BookCopy entity)
		{
			this.SendPropertyChanging();
			entity.Book = this;
		}