示例#1
0
        public void DeleteAuthor(BookAuthor model)
        {
            var result         = GetAuthorById(model.AuthorId);
            var deletableBooks = _db.Books.Where(e => e.AuthorId == model.AuthorId);

            _db.Books.RemoveRange(deletableBooks);
            _db.BookAuthors.Remove(result);

            _db.SaveChanges();
        }
示例#2
0
 public void AddAuthor(BookAuthor model)
 {
     _db.BookAuthors.Add(model);
     _db.SaveChanges();
 }