public IActionResult Cars(int id) { var generation = generationsService.GetById(id); if (generation == null) { return(this.BadRequest()); } var imageUrls = imagesService.GetImageUrls(GlobalConstants.GENERATION_PHOTO_PATH_TEMPLATE, id.ToString()); var cars = carsService.GetAllForGeneration(id) .To <DisplayCarWithEngineModel>() .ToList(); var viewModel = new DisplayCarsWithImagesModel { Cars = cars, ImageUrls = imageUrls }; viewModel.GenerationId = generation.Id; this.ViewBag.Make = generation.Model.Make.Name; this.ViewBag.Model = generation.Model.Name; this.ViewBag.Generation = generation.Name; return(this.View(viewModel)); }
public IActionResult Details(string id) { var userId = userManager.GetUserId(this.User); var userCar = this.userCarsService.GetById(id); if (!userCar.IsPublic && userCar.OwnerId != userId && !User.IsInRole("Admin")) { return(this.Unauthorized()); } if (userCar == null) { return(this.BadRequest()); } var viewModel = Mapper.Map <DetailsUserCarModel>(userCar); viewModel.ImageUrls = imagesService.GetImageUrls(GlobalConstants.USERCAR_PHOTO_PATH_TEMPLATE, userCar.Id); return(this.View(viewModel)); }