static void AddBook(Book book) { using (Library2Entities db = new Library2Entities()) { db.Book.Add(book); db.SaveChanges(); Console.WriteLine($"New book aded!"); } }
static void AddAuthor(Author author) { using (Library2Entities db = new Library2Entities()) { db.Author.Add(author); db.SaveChanges(); Console.WriteLine($"New author success added! {author.LastName}"); } }
//Заполнение БД static void AddPublisher(Publisher publisher) { using (Library2Entities db = new Library2Entities()) { Publisher a = db.Publisher.Where(pub => pub.PublisherName == publisher.PublisherName).FirstOrDefault(); if (a == null) { db.Publisher.Add(publisher); db.SaveChanges(); Console.WriteLine($"New publisher aded!"); } } }