public async Task <IActionResult> PutVehicle([FromRoute] int id, [FromBody] VehicleAddOrChangeRequest request)
        {
            if (!ModelState.IsValid || !TryValidateModel(request))
            {
                return(BadRequest(ModelState.Values.SelectMany(m => m.Errors)));
            }

            var vehicle = _mapper.Map <Vehicle>(request);

            var currentVehicle = await _repo.GetByIdWithoutTrackingAsync(id);

            if (currentVehicle is null)
            {
                return(NotFound());
            }

            if (!doesUserOwnVehicle(currentVehicle.OwnerId))
            {
                return(Unauthorized());
            }

            vehicle.VehicleId = id;
            vehicle.OwnerId   = currentVehicle.OwnerId;

            var updateSucceed = await _repo.UpdateAsync(vehicle);

            if (!updateSucceed)
            {
                return(NotFound());
            }

            return(Ok(vehicle));
        }
        public async Task <IActionResult> PostVehicle([FromBody] VehicleAddOrChangeRequest request)
        {
            if (!ModelState.IsValid || !TryValidateModel(request))
            {
                return(BadRequest(ModelState.Values.SelectMany(m => m.Errors)));
            }

            if (!doesUserOwnVehicle(request.OwnerId))
            {
                return(Unauthorized());
            }

            var vehicle = _mapper.Map <Vehicle>(request);

            await _repo.AddAsync(vehicle);

            return(CreatedAtAction("GetVehicle", new { id = vehicle.VehicleId }, vehicle));
        }