public ActionResult Add(ComicBookArtistsAddViewModel viewModel) { ValidateComicBookArtist(viewModel); if (ModelState.IsValid) { var comicBookArtist = new ComicBookArtist() { ComicBookId = viewModel.ComicBookId, ArtistId = viewModel.ArtistId, RoleId = viewModel.RoleId }; _comicBooksArtistRepository.Add(comicBookArtist); TempData["Message"] = "Your artist was successfully added!"; return(RedirectToAction("Detail", "ComicBooks", new { id = viewModel.ComicBookId })); } // TODO Prepare the view model for the view. // TODO Get the comic book. // Include the "Series" navigation property. viewModel.ComicBook = _comicBooksRepository.Get(viewModel.ComicBookId); viewModel.Init(Repository, _artistsRepository); return(View(viewModel)); }
public ActionResult Add(ComicBookArtistsAddViewModel viewModel) { ValidateComicBookArtist(viewModel); if (ModelState.IsValid) { var comicBookArtist = new ComicBookArtist() { ComicBookId = viewModel.ComicBookId, ArtistId = viewModel.ArtistId, RoleId = viewModel.RoleId }; _comicBookArtistsRepository.Add(comicBookArtist); TempData["Message"] = "Your artist was successfully added!"; return(RedirectToAction("Detail", "ComicBooks", new { id = viewModel.ComicBookId })); } viewModel.ComicBook = _comicBooksRepository.GetById(viewModel.ComicBookId); viewModel.Init(Context); return(View(viewModel)); }
public ActionResult Add(ComicBookArtistsAddViewModel viewModel) { ValidateComicBookArtist(viewModel); if (ModelState.IsValid) { ComicBookArtist comicbookArtist = new ComicBookArtist() { ComicBookId = viewModel.ComicBookId, ArtistId = viewModel.ArtistId, RoleId = viewModel.RoleId }; _comicBookArtistRepository.Add(comicbookArtist); TempData["Message"] = "Your artist was successfully added!"; return(RedirectToAction("Detail", "ComicBooks", new { id = viewModel.ComicBookId })); } var comicbook = _comicBooksRepository.Get(viewModel.ComicBookId); if (comicbook == null) { return(new HttpStatusCodeResult(HttpStatusCode.NotFound)); } viewModel.ComicBook = comicbook; viewModel.Init(ArtistRepository, RoleRepository); return(View(viewModel)); }
public ActionResult Add(ComicBookArtistsAddViewModel viewModel) { ValidateComicBookArtist(viewModel); if (ModelState.IsValid) { var comicBookArtist = new ComicBookArtist() { ComicBookId = viewModel.ComicBookId, ArtistId = viewModel.ArtistId, RoleId = viewModel.RoleId }; _context.ComicBookArtists.Add(comicBookArtist); _context.SaveChanges(); TempData["Message"] = "Your artist was successfully added!"; return(RedirectToAction("Detail", "ComicBooks", new { id = viewModel.ComicBookId })); } viewModel.ComicBook = _context.ComicBooks .Include(cb => cb.Series) .Where(cb => cb.Id == viewModel.ComicBookId) .SingleOrDefault(); viewModel.Init(_context); return(View(viewModel)); }
public ActionResult Add(ComicBookArtistsAddViewModel viewModel) { ValidateComicBookArtist(viewModel); if (ModelState.IsValid) { // Add the comic book artist var comicBookArtist = new ComicBookArtist() { ComicBookId = viewModel.ComicBookId, ArtistId = viewModel.ArtistId, RoleId = viewModel.RoleId }; _comicBookArtistsRepository.Add(comicBookArtist); TempData["Message"] = "Your artist was successfully added!"; return(RedirectToAction("Detail", "ComicBooks", new { id = viewModel.ComicBookId })); } // Prepare the view model for the view viewModel.ComicBook = _comicBooksRepository.Get(viewModel.ComicBookId, includeSeries: true); viewModel.Init(Context); return(View(viewModel)); }
public ActionResult Add(int comicBookId) { var comicBook = _comicBooksRepository.GetById(comicBookId); if (comicBook == null) { return(HttpNotFound()); } var viewModel = new ComicBookArtistsAddViewModel() { ComicBook = comicBook }; viewModel.Init(Context); return(View(viewModel)); }
public ActionResult Add(int comicBookId) { var comicBook = new GetComicbookQuery(Context).Execute(comicBookId); if (comicBook == null) { return(HttpNotFound()); } var viewModel = new ComicBookArtistsAddViewModel() { ComicBook = comicBook }; viewModel.Init(Repository, _artistRepository); return(View(viewModel)); }
public ActionResult Add(ComicBookArtistsAddViewModel viewModel) { ValidateComicBookArtist(viewModel); if (ModelState.IsValid) { new AddComicBookArtistCommand(Context).Execute(viewModel.ComicBookId, viewModel.ArtistId, viewModel.RoleId); TempData["Message"] = "Your artist was successfully added!"; return(RedirectToAction("Detail", "ComicBooks", new { id = viewModel.ComicBookId })); } viewModel.ComicBook = new GetComicBookQuery(Context).Execute(viewModel.ComicBookId); viewModel.Init(Repository, _artistsRepository); return(View(viewModel)); }
public ActionResult Add(int comicBookId) { // Retrieve a query thst the user is adding an artist to var comicBook = new GetComicBookQuery(Context).Execute(comicBookId); if (comicBook == null) { return(HttpNotFound()); } var viewModel = new ComicBookArtistsAddViewModel() { ComicBook = comicBook }; viewModel.Init(Repository, _artistsRepository); return(View(viewModel)); }
public ActionResult Add(int comicBookId) { // Include the "Series" navigation property. var comicBook = _comicBooksRepository.Get(comicBookId); if (comicBook == null) { return(HttpNotFound()); } var viewModel = new ComicBookArtistsAddViewModel() { ComicBook = comicBook }; viewModel.Init(Repository); return(View(viewModel)); }
public ActionResult Add(int comicBookId) { // Get the comic book. var comicBook = _comicBooksRepository.Get(comicBookId); if (comicBook == null) { return(HttpNotFound()); } var viewModel = new ComicBookArtistsAddViewModel() { ComicBook = comicBook }; // Pass the Context class to the view model "Init" method. viewModel.Init(Repository); return(View(viewModel)); }
public ActionResult Add(int comicBookId) { var comicBook = _context.ComicBooks .Include(cb => cb.Series) .Where(cb => cb.Id == comicBookId) .SingleOrDefault();; if (comicBook == null) { return(HttpNotFound()); } var viewModel = new ComicBookArtistsAddViewModel() { ComicBook = comicBook }; viewModel.Init(_context); return(View(viewModel)); }
public ActionResult Add(int comicBookId) { // TODO Get the comic book. // Include the "Series" navigation property. var comicBook = _comicBooksRepository.GetDetailById(comicBookId); if (comicBook == null) { return(HttpNotFound()); } var viewModel = new ComicBookArtistsAddViewModel() { ComicBook = comicBook }; // TODO Pass the Context class to the view model "Init" method. viewModel.Init(Repository); return(View(viewModel)); }
public ActionResult Add(ComicBookArtistsAddViewModel viewModel) { ValidateComicBookArtist(viewModel); if (ModelState.IsValid) { var artist = Repository.GetArtist(viewModel.ArtistId); var role = Repository.GetRole(viewModel.RoleId); viewModel.ComicBook.AddArtist(artist, role); Repository.SaveChanges(); TempData["Message"] = "Your artist was successfully added!"; return(RedirectToAction("Detail", "ComicBooks", new { id = viewModel.ComicBookId })); } viewModel.Init(Repository); return(View(viewModel)); }
public ActionResult Add(ComicBookArtistsAddViewModel viewModel) { ValidateComicBookArtist(viewModel); if (ModelState.IsValid) { // TODO Add the comic book artist. TempData["Message"] = "Your artist was successfully added!"; return(RedirectToAction("Detail", "ComicBooks", new { id = viewModel.ComicBookId })); } // TODO Prepare the view model for the view. // TODO Get the comic book. // Include the "Series" navigation property. viewModel.ComicBook = new ComicBook(); // TODO Pass the Context class to the view model "Init" method. viewModel.Init(); return(View(viewModel)); }