示例#1
0
 static void AddUsers(Users user)
 {
     using (Library2Entities db = new Library2Entities())
     {
         db.Users.Add(user);
         Console.WriteLine("New User Added:" + user.UserLastName);
         db.SaveChanges();
     }
 }
示例#2
0
 static void AddBook(Book book)
 {
     using (Library2Entities db = new Library2Entities())
     {
         db.Book.Add(book);
         db.SaveChanges();
         Console.WriteLine("New Book Added:" + book.Title);
     }
 }
示例#3
0
 static void AddAuthor(Author author)
 {
     using (Library2Entities db = new Library2Entities())
     {
         db.Author.Add(author);
         db.SaveChanges();
         Console.WriteLine("New Author Added:" + author.LastName);
     }
 }
示例#4
0
        static void AllDebtorsNull()  //Обнуление долгов
        {
            using (Library2Entities db = new Library2Entities())
            {
                var debtors = db.Users.Where(u => u.IsDebtor == true).ToList();

                Console.WriteLine("Должники");
                foreach (var item in debtors)
                {
                    item.IsDebtor = false;
                    db.SaveChanges();
                    Console.WriteLine("{0} {1}", item.UserLastName, item.IsDebtor);
                }
            }
        }