/// <summary> /// Lists the detail for the provided comic book ID. /// </summary> /// <param name="comicBookId">The comic book ID to list detail for.</param> private static void ListComicBook(int comicBookId) { _comicBookRepository = new ComicBooksRepository(context); ComicBook comicBook = _comicBookRepository.Get(comicBookId); ConsoleHelper.ClearOutput(); ConsoleHelper.OutputLine("COMIC BOOK DETAIL"); ConsoleHelper.OutputLine(comicBook.DisplayText); if (!string.IsNullOrWhiteSpace(comicBook.Description)) { ConsoleHelper.OutputLine(comicBook.Description); } ConsoleHelper.OutputBlankLine(); ConsoleHelper.OutputLine("Published On: {0}", comicBook.PublishedOn.ToShortDateString()); ConsoleHelper.OutputLine("Average Rating: {0}", comicBook.AverageRating != null ? comicBook.AverageRating.Value.ToString("n2") : "N/A"); ConsoleHelper.OutputLine("Artists"); foreach (ComicBookArtist artist in comicBook.Artists) { ConsoleHelper.OutputLine("{0} - {1}", artist.Artist.Name, artist.Role.Name); } context.Dispose(); }
public ActionResult Add(int comicBookId) { 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) { ComicBook comicBook = _comicBooksRepository.Get(comicBookId, includeSeries: true); if (comicBook == null) { return(HttpNotFound()); } var viewModel = new ComicBookArtistsAddViewModel() { ComicBook = comicBook }; viewModel.Init(Context); return(View(viewModel)); }
public ActionResult Detail(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var comicBook = _comicBooksRepository.Get((int)id); if (comicBook == null) { return(HttpNotFound()); } // Sort the artists. comicBook.Artists = comicBook.Artists.OrderBy(a => a.Role.Name).ToList(); return(View(comicBook)); }
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 Detail(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } // TODO Get the comic book. // Include the "Series", "Artists.Artist", and "Artists.Role" navigation properties. var comicBook = _comicBooksRepository.Get((int)id); if (comicBook == null) { return(HttpNotFound()); } // Sort the artists. comicBook.Artists = comicBook.Artists.OrderBy(a => a.Role.Name).ToList(); return(View(comicBook)); }
/// <summary> /// Lists the editable properties for the provided comic book ID /// and prompts the user to select a property to edit. /// </summary> /// <param name="comicBookId">The comic book ID to update.</param> private static void UpdateComicBook(int comicBookId) { _comicBookRepository = new ComicBooksRepository(context); ComicBook comicBook = _comicBookRepository.Get(comicBookId); string command = CommandListComicBookProperties; // If the current command doesn't equal the "Cancel" command // then evaluate and process the command. while (command != CommandCancel) { switch (command) { case CommandListComicBookProperties: ListComicBookProperties(comicBook); break; case CommandSave: _comicBookRepository.Update(comicBook); command = CommandCancel; continue; default: if (AttemptUpdateComicBookProperty(command, comicBook)) { command = CommandListComicBookProperties; continue; } else { ConsoleHelper.OutputLine("Sorry, but I didn't understand that command."); } break; } // List the available commands. ConsoleHelper.OutputBlankLine(); ConsoleHelper.Output("Commands: "); if (EditableProperties.Count > 0) { ConsoleHelper.Output("Enter a Number 1-{0}, ", EditableProperties.Count); } ConsoleHelper.OutputLine("S - Save, C - Cancel", false); // Get the next command from the user. command = ConsoleHelper.ReadInput("Enter a Command: ", true); } context.Dispose(); ConsoleHelper.ClearOutput(); }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var comicBook = comicBooksRepository.Get(id.Value, true); if (comicBook == null) { return(HttpNotFound()); } var viewModel = new ComicBooksEditViewModel() { ComicBook = comicBook }; viewModel.Init(Repository); return(View(viewModel)); }