public async Task <ActionResult <string> > PostAsync([FromBody] ServiceMetricsWrapperRequest serviceMetricsWrapperRequest) { if (serviceMetricsWrapperRequest.Journeys.Count > 4) { return(new BadRequestObjectResult("Cannot have more than 4 requests")); } var serviceMetricsList = serviceMetricsMapper.MapServiceMetrics(serviceMetricsWrapperRequest); var serviceMetricsRequests = serviceMetricsRequestBuilder.ServiceMetrics(serviceMetricsList); var serviceMetricResponses = await serviceMetric.GetResposesAsync(serviceMetricsRequests); var rids = new List <string>(); foreach (var serviceMetricResponse in serviceMetricResponses) { foreach (var service in serviceMetricResponse.Services) { foreach (var rid in service.serviceAttributesMetrics.rids) { rids.Add(rid); } } } var serviceMetricsWrapperResponse = new ServiceMetricsWrapperResponse { Rids = rids }; return(new OkObjectResult(serviceMetricsWrapperResponse)); }
public List <ServiceMetricsRequest> MapServiceMetrics(ServiceMetricsWrapperRequest serviceMetricsWrapperRequest) { var serviceMetricsRequestList = new List <ServiceMetricsRequest>(); foreach (var serviceMetricsWrapperRequestJourney in serviceMetricsWrapperRequest.Journeys) { var serviceMetricsRequest = AutoMapper.Mapper.Map <ServiceMetricsRequest>(serviceMetricsWrapperRequest); serviceMetricsRequest.FromStation = serviceMetricsWrapperRequestJourney.FromStation; serviceMetricsRequest.ToStation = serviceMetricsWrapperRequestJourney.ToStation; serviceMetricsRequestList.Add(serviceMetricsRequest); } return(serviceMetricsRequestList); }