static void AddUsers(Users user) { using (Library2Entities db = new Library2Entities()) { db.Users.Add(user); Console.WriteLine("New User Added:" + user.UserLastName); db.SaveChanges(); } }
static void AddBook(Book book) { using (Library2Entities db = new Library2Entities()) { db.Book.Add(book); db.SaveChanges(); Console.WriteLine("New Book Added:" + book.Title); } }
static void AddAuthor(Author author) { using (Library2Entities db = new Library2Entities()) { db.Author.Add(author); db.SaveChanges(); Console.WriteLine("New Author Added:" + author.LastName); } }
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); } } }