public virtual IActionResult Put(string id, [FromBody] VehicleInfo vehicle)
        {
            // TODO: implement Put(string, VehicleInfo) properly
            if (vehicle == null)
            {
                return(BadRequest(ErrorResponseInfo.BadRequestError(1, "missing product", nameof(vehicle))));
            }
            if (string.IsNullOrWhiteSpace(id))
            {
                return(BadRequest(ErrorResponseInfo.BadRequestError(1, "missing product id", nameof(id))));
            }
            var existing = repository.FindById(id);

            try
            {
                if (existing == null)
                {
                    repository.AddNewVehicle(id, vehicle.ToVehicle());
                    return(CreatedAtRoute(GetByIdRouteName,
                                          new { id }, vehicle));
                }

                repository.ReplaceExistingVehicle(id, vehicle.ToVehicle());
            }
            catch (VehicleConstraintViolatedException exception)
            {
                return(BadRequest(ErrorResponseInfo.BadRequestError(2, $"invalid vehicle body {exception.Message}",
                                                                    nameof(vehicle))));
            }

            return(NoContent());
        }
        public virtual IActionResult Post([FromBody] VehicleInfo vehicle)
        {
            if (vehicle == null)
            {
                return(BadRequest(ErrorResponseInfo.BadRequestError(1, "missing product", nameof(vehicle))));
            }
            var vehicleId = repository.AddNewVehicle(vehicle.ToVehicle());

            vehicle.VehicleIdentifier = vehicleId;
            return(CreatedAtRoute(GetByIdRouteName,
                                  new { id = vehicleId }, vehicle));
        }
        public virtual ActionResult <VehicleInfo> Get(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                return(BadRequest(ErrorResponseInfo.BadRequestError(1, "missing product id", nameof(id))));
            }
            var vehicle = repository.FindById(id);

            if (vehicle == null)
            {
                return(new NotFoundResult());
            }

            return(Ok(new VehicleInfo(vehicle)));
        }