public List<Author> GetAuthors() { using (var context = new AuthorDbContext()) { return context.Authors.ToList(); } }
public List<Book> GetBooks() { using (var context = new AuthorDbContext()) { return context.Books.ToList(); } }
public Author Edit(int id) { using (var context = new AuthorDbContext()) { Author author = context.Authors.Find(id); return author; } }
public List<Author> EditComplite(Author author) { using (var context = new AuthorDbContext()) { context.Entry(author).State = EntityState.Modified; context.SaveChanges(); return context.Authors.ToList(); } }
public List<Book> Create(Book book) { using (var context = new AuthorDbContext()) { context.Books.Add(book); context.SaveChanges(); return context.Books.ToList(); } }
public List<Author> Create(Author author) { using (var context = new AuthorDbContext()) { context.Authors.Add(author); context.SaveChanges(); return context.Authors.ToList(); } }
public List<Author> DeleteConfirmed(int id) { using (var context = new AuthorDbContext()) { Author author = context.Authors.Find(id); context.Authors.Remove(author); context.SaveChanges(); return context.Authors.ToList(); } }