예제 #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();
            }
        }