public async Task <IActionResult> Create(CarRatingCreateInputModel carRatingCreateInputModel, int id) { var currentUser = await this.userManager.GetUserAsync(this.User); var trip = await this.tripsService.GetByIdAsync <MyTripsServiceAllModel>(id); var carId = trip.CarId; if (!this.ModelState.IsValid) { carRatingCreateInputModel.ClientId = currentUser.Id; carRatingCreateInputModel.TripId = trip.Id; carRatingCreateInputModel.CarId = carId; return(this.View(carRatingCreateInputModel)); } carRatingCreateInputModel.ClientId = currentUser.Id; carRatingCreateInputModel.TripId = trip.Id; carRatingCreateInputModel.CarId = carId; var carRatingServiceModel = carRatingCreateInputModel.To <CarRatingServiceInputModel>(); await this.carsRatingsService.CreateAsync(carRatingServiceModel); await this.tripsService.VoteAsync(trip.Id); return(this.Redirect("/Trips/MyTrips")); }
public async Task <IActionResult> Create(int id) { var currentUser = await this.userManager.GetUserAsync(this.User); var tripServiceModel = await this.tripsService.GetByIdAsync <MyTripsServiceAllModel>(id); var carServiceModel = await this.carsService.GetByIdAsync <CarServiceDetailsModel>(tripServiceModel.CarId); var viewModel = new CarRatingCreateInputModel() { ClientId = currentUser.Id, TripId = tripServiceModel.Id, CarId = carServiceModel.Id, }; return(this.View(viewModel)); }