Example #1
0
 static Authors GetAuthorByName1(string fname)
 {
     using (LibraryEntities db = new LibraryEntities())
     {
         var author = db.Authors.FirstOrDefault(x => x.FirstName == fname);
         return(author);
     }
 }
Example #2
0
 static Authors GetAuthorById1(int id)
 {
     using (LibraryEntities db = new
                                 LibraryEntities())
     {
         var author = db.Authors.SingleOrDefault(x => x.Id == id);
         return(author);
     }
 }
Example #3
0
 private static void AddAuthor(Authors author)
 {
     using (LibraryEntities db = new LibraryEntities())
     {
         db.Authors.Add(author);
         db.SaveChanges();
         Console.WriteLine("New author added:" + author.LastName);
     }
 }
Example #4
0
 static Authors GetAuthorById(int id)
 {
     using (LibraryEntities db = new LibraryEntities())
     {
         var au = db.Authors.Find(id);
         Console.WriteLine(au.FirstName + " " +
                           au.LastName);
         return(au);
     }
 }
Example #5
0
 static void GetAllAuthors1()
 {
     using (LibraryEntities db = new LibraryEntities())
     {
         var au = db.Authors.OrderBy((x) => x.LastName).ToList();
         foreach (var a in au)
         {
             Console.WriteLine(a.FirstName + " " + a.LastName);
         }
     }
 }
Example #6
0
 static void AddBook(Books book)
 {
     using (LibraryEntities db = new LibraryEntities())
     {
         Books a = db.Books.FirstOrDefault(x => x.Title == book.Title);
         if (a == null)
         {
             db.Books.Add(book);
         }
         db.SaveChanges();
         Console.WriteLine("New book added:" + book.Title);
     }
 }
Example #7
0
        private static void GetAllBook()
        {
            using (LibraryEntities db = new LibraryEntities())
            {
                //var au = db.Books.OrderBy((x) => x.Title).ToList();
                //foreach (var a in au)
                //{
                //    Console.WriteLine("Book: " + a.Title + "\tprice: " + a.PRICE + " \tauthor: "+a.Authors.FirstName + " " + a.Authors.LastName);

                //}
                var au = db.Books.Find(1004);
                Console.WriteLine("Book: " + au.Title + "\tprice: " + au.PRICE + " \tauthor: " + au.Authors.FirstName + " " + au.Authors.LastName);
            }
        }
Example #8
0
 private static void GetAllPersonal()
 {
     using (LibraryEntities db = new LibraryEntities())
     {
         var au = db.Personal.ToList();
         foreach (var a in au)
         {
             Console.WriteLine(a.Login + " " + a.Adres + " Должник " + a.Admin);
         }
         //var au = db.Authors.Where((x) => x.LastName.StartsWith("A")).ToList();
         //foreach (var a in au)
         //{
         //    Console.WriteLine(a.FirstName + " " + a.LastName);
         //}
     }
 }