示例#1
0
        public async Task <IActionResult> AddVehicleToLocation(Guid locationId, [FromBody] VehicleModel vehicleModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var vehicle = dataStructureConverter.Map <Vehicle, VehicleModel>(vehicleModel);

            var result = await locationService.AddVehicle(locationId, vehicle);

            if (result.ResultCode == ResultCode.Success)
            {
                return(Created("GetVehicle", result.Data));
            }

            return(errorCodeConverter.Convert(result.ResultCode));
        }