示例#1
0
 public List<Author> GetAuthors()
 {
     using (var context = new AuthorDbContext())
     {
         return context.Authors.ToList();
     }
 }
示例#2
0
 public List<Book> GetBooks()
 {
     using (var context = new AuthorDbContext())
     {
         return context.Books.ToList();
     }
 }
示例#3
0
 public Author Edit(int id)
 {
     using (var context = new AuthorDbContext())
     {
         Author author = context.Authors.Find(id);
         return author;
     }
 }
示例#4
0
        public List<Author> EditComplite(Author author)
        {
            using (var context = new AuthorDbContext())
            {
                context.Entry(author).State = EntityState.Modified;
                context.SaveChanges();

                return context.Authors.ToList();
            }
        }
示例#5
0
        public List<Book> Create(Book book)
        {
            using (var context = new AuthorDbContext())
            {
                context.Books.Add(book);

                context.SaveChanges();

                return context.Books.ToList();
            }
        }
示例#6
0
        public List<Author> Create(Author author)
        {
            using (var context = new AuthorDbContext())
            {
                context.Authors.Add(author);

                context.SaveChanges();

                return context.Authors.ToList();
            }
        }
示例#7
0
        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();
            }
        }