示例#1
0
 static void AddAuthor(Authors aut)
 {
     using (PublishingHouseEntities db = new PublishingHouseEntities())
     {
         db.Authors.Add(aut);
         db.SaveChanges();
         Console.WriteLine("New author with name " + aut.FirstName + " " + aut.LastName + " added");
     }
 }
示例#2
0
 static Authors GetAuthorsByName(string name)
 {
     using (PublishingHouseEntities db = new PublishingHouseEntities())
     {
         var author = (from a in db.Authors
                       where a.FirstName == name
                       select a).FirstOrDefault(); // if not, return null
         return(author);
     }
 }
示例#3
0
        static void ShowAuthors()
        {
            using (PublishingHouseEntities db = new PublishingHouseEntities())
            {
                var books = db.Books.ToList();

                foreach (var item in books)
                {
                    Console.WriteLine($"{item.NameBook}  {item.Authors.FirstName}");
                }
            }
        }
示例#4
0
        static void AddBook(Books _book)
        {
            using (PublishingHouseEntities db = new PublishingHouseEntities())
            {
                Books currbook = db.Books.Where(b => b.NameBook == _book.NameBook).FirstOrDefault();

                if (currbook == null)
                {
                    db.Books.Add(_book);
                    db.SaveChanges();
                    Console.WriteLine("Книга добавлена");
                }
            }
        }
示例#5
0
        static void AddTheme(Themes theme)
        {
            using (PublishingHouseEntities db = new PublishingHouseEntities())
            {
                Themes t = db.Themes.Where(h => h.NameTheme == theme.NameTheme).FirstOrDefault();

                if (t == null)
                {
                    db.Themes.Add(theme);
                    db.SaveChanges();
                    Console.WriteLine("Тема добавлена");
                }
            }
        }