public ActionResult RemoveAuthors(AddAuthorsCreate model) { var service = CreateAuthorBookService(); service.RemoveAuthor(model); return(RedirectToAction("Index", "Book")); }
public ActionResult AddAuthors(AddAuthorsCreate model) { var service = CreateAuthorPublisherService(); service.AddAuthor(model); return(RedirectToAction("Index", "Publisher")); }
public ActionResult AddAuthors(AddAuthorsCreate model) { var service = CreateAuthorConventionService(); service.AddAuthor(model); return(RedirectToAction("Index", "Convention")); }
public ActionResult AddAuthors(AddAuthorsCreate model) { var service = CreateSeriesAuthorService(); service.AddAuthor(model); return(RedirectToAction("Index", "Series")); }
public bool AddAuthor(AddAuthorsCreate model) { foreach (int authorId in model.Authors) { var entity = new AuthorBook() { AuthorId = authorId, BookId = model.BookId }; using (var ctx = new ApplicationDbContext()) { ctx.AuthorBooks.Add(entity); var changes = ctx.SaveChanges(); } } return(true); }
public bool RemoveAuthor(AddAuthorsCreate model) { foreach (int authorId in model.Authors) { var entity = new SeriesAuthor() { AuthorId = authorId, SeriesId = model.SeriesId }; using (var ctx = new ApplicationDbContext()) { ctx.SeriesAuthors.Attach(entity); ctx.SeriesAuthors.Remove(entity); var changes = ctx.SaveChanges(); } } return(true); }