public async Task <IActionResult> Create(CreateFishListInputModel input) { if (!this.ModelState.IsValid) { var viewModel = new CreateFishListInputModel(); viewModel.FishSpeciesItems = this.fishSpeciesService.GetAllForSelectList(); return(this.View(viewModel)); } var tripId = input.TripId; foreach (var fishModel in input.Fish) { var fishId = await this.fishService.CreateAsync(fishModel, tripId); var imagesUris = await this.cloudinaryService.UploadAsync(this.cloudinary, fishModel.Images.ToList()); foreach (var imageUri in imagesUris) { await this.imageService.CreateAsync(imageUri, fishId); } } return(this.RedirectToAction(nameof(TripsController.ById), nameof(TripsController).Replace("Controller", string.Empty), new { id = tripId })); }
public IActionResult Create(AddFishRouteData routeData) { this.ViewData["FishCount"] = routeData.FishCount; this.ViewData["TripId"] = routeData.TripId; var viewModel = new CreateFishListInputModel(); viewModel.FishSpeciesItems = this.fishSpeciesService.GetAllForSelectList(); return(this.View(viewModel)); }