public async Task <IActionResult> PostCarRate(long id, [FromBody] CarVehicleRatingDTO model)
        {
            if (ModelState.IsValid)
            {
                CarReservation vehicleReser = await _reservationService.GetCarReservationById(id);

                Vehicle vehicle = await _vehicleService.GetVehicleById(vehicleReser.VehicleId);

                RegularUser user = await _userService.GetCurrentUser();

                CarCompanyRating ccRate = new CarCompanyRating();
                ccRate.CarReservationId = id;
                ccRate.CarCompanyId     = vehicle.CarCompanyId;
                ccRate.UserId           = user.Id;
                ccRate.Rate             = model.ratingCarCompany;

                VehicleRating vehicleRate = new VehicleRating();
                vehicleRate.CarReservationId = id;
                vehicleRate.VehicleId        = vehicle.VehicleId;
                vehicleRate.Rate             = model.ratingVehicle;
                vehicleRate.UserId           = user.Id;

                await _userService.AddCarRating(ccRate);

                await _userService.AddVehicleRating(vehicleRate);

                return(Ok(200));
            }
            return(BadRequest());
        }
        public async Task AddCarRating(CarCompanyRating ccr)
        {
            await _context.CarCompanyRatings.AddAsync(ccr);

            await _context.SaveChangesAsync();
        }
Example #3
0
 public async Task AddCarRating(CarCompanyRating acr)
 {
     await _userRepository.AddCarRating(acr);
 }