public async Task <VehicleTypeResponse> Create(CreateVehicleTypeRequest request) { VehicleTypeResponse response = new VehicleTypeResponse(); CreateVehicleTypeCommand vehicleTypeCommand = new CreateVehicleTypeCommand { Code = request.Code, Name = request.Name }; try { var result = _bus.SendCommand(vehicleTypeCommand); Task <object> status = result as Task <object>; var isComplete = (bool)status.Result; if (isComplete) { response.Status = new ResponseModel.StatusResponse { Content = "Sucess", OK = true }; } else { response.Status = new ResponseModel.StatusResponse { Content = "Error!", OK = false }; } } catch (Exception ex) { response.Status = new ResponseModel.StatusResponse { Content = ex.Message, OK = false }; } return(await Task.FromResult(response)); }
public async Task <IActionResult> Post([FromBody] CreateVehicleTypeRequest request) { var result = await _vehicleTypeAppService.Create(request); return(Ok(result)); }