public ActionResult RemoveBooks(AddBooksCreate model) { var service = CreateSeriesBookService(); service.RemoveBook(model); return(RedirectToAction("Index", "Series")); }
public ActionResult AddBooks(AddBooksCreate model) { var service = CreateAuthorBookService(); service.AddBook(model); return(RedirectToAction("Index", "Author")); }
public ActionResult RemoveBooks(AddBooksCreate model) { var service = CreateBookPublisherService(); service.RemoveBook(model); return(RedirectToAction("Index", "Publisher")); }
public bool AddBook(AddBooksCreate model) { foreach (int bookId in model.Books) { var entity = new AuthorBook() { AuthorId = model.AuthorId, BookId = bookId }; using (var ctx = new ApplicationDbContext()) { ctx.AuthorBooks.Add(entity); var changes = ctx.SaveChanges(); } } return(true); }
public bool RemoveBook(AddBooksCreate model) { foreach (int bookId in model.Books) { var entity = new BookPublisher() { BookId = bookId, PublisherId = model.PublisherId }; using (var ctx = new ApplicationDbContext()) { ctx.BookPublishers.Attach(entity); ctx.BookPublishers.Remove(entity); var changes = ctx.SaveChanges(); } } return(true); }