public async Task <IActionResult> Get(Guid customerId) { //call mediator var request = new Mediator.VehicleRequest( ControllerContext , new VehicleFilter { CustomerId = customerId }, _messageRequest, _middlewareConfiguration, _correlationId, _operationalUnit ); var result = await _mediator.Send(request); //transform the result model var trackingResult = result?.Select(t => new VehicleResponse(t)).FirstOrDefault(); return(new JsonResult(trackingResult)); }
public async Task <IEnumerable <DomainModels.Business.VehicleDomain.Vehicle> > Handle(VehicleRequest request, CancellationToken cancellationToken) { _logger.LogInformation($"Request => {nameof(VehicleRequest)}"); //add correlation id request.Controller.HttpContext.Request.Headers.Add(DomainModels.Types.Identifiers.CorrelationId, new StringValues(request.CorrelationId.ToString())); var VehicleFilterModel = new VehicleFilterModel { Header = new MessageHeader { CorrelationId = request.CorrelationId }, Body = request.Model, Footer = new MessageFooter { Sender = DomainModels.System.Identifiers.TrackingServiceName, FingerPrint = request.Controller.ActionDescriptor.Id, Environment = request.OperationalUnit.Environment, Assembly = request.OperationalUnit.Assembly, Route = JsonConvert.SerializeObject(new Dictionary <string, string> { { DomainModels.System.Identifiers.MessagePublisherRoute, request.MiddlewareConfiguration.MessagePublisherRoute } }, Defaults.JsonSerializerSettings), Hint = Enum.GetName(typeof(ResponseHint), ResponseHint.OK) } }; return(await await new Function(_logger, DomainModels.System.Identifiers.RetryCount).Decorate(async() => { return await request.MessageRequest.Request(VehicleFilterModel); })); }