public ActionResult Details(int?id, string returnUrl) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var publisher = db.Publishers.Include(a => a.Books).FirstOrDefault(a => a.Id == id); if (publisher == null) { return(HttpNotFound()); } var booksByPublisher = publisher.Books.ToList(); var model = new PublisherDetailsViewModel() { Publisher = publisher, BooksByPublisher = booksByPublisher }; ViewBag.ReturnUrl = returnUrl; return(View(model)); }
public ActionResult Details(int?id) { _logger.Information("Action: Details; Controller: Publisher; Call method: GET;"); try { if (id == null) { return(View("NotFound")); } var publisherModel = _publisherService.GetPublisherById(id.ToString()); if (publisherModel.IsRemoved == true) { return(View("NotFound")); } var userId = User.Identity.GetUserId(); var model = new PublisherDetailsViewModel { Publisher = publisherModel, UserId = userId }; return(View(model)); } catch (Exception e) { LogException(e); return(RedirectToAction("Index", "Error", new { exceptionType = e.GetType().Name })); } }
public ActionResult GetPublisherDetails(Guid publisherId) { var publisher = _publisherService.GetPublisher(publisherId); var model = new PublisherDetailsViewModel(); Mapper.Map(publisher, model); return(View("PublisherDetails", model)); }
public IActionResult Details(int id) { if (id == 0) { return(NotFound()); } Publisher publisher = publisherService.GetByID(id); if (publisher == null) { return(NotFound()); } PublisherDetailsViewModel viewModel = new PublisherDetailsViewModel(); viewModel.Publisher = publisher; return(View(viewModel)); }