예제 #1
0
        public async Task <HttpResponseMessage> GetFilteredServices(HttpRequestMessage request, bool filterServices)
        {
            var content = await request.Content.ReadAsStringAsync();

            var dosCaseRequest = BuildRequestMessage(GetObjectFromRequest <DosCase>(content));
            var response       = await _dosService.GetServices(dosCaseRequest);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                return(response);
            }

            var dosFilteredCase = GetObjectFromRequest <DosFilteredCase>(content);

            var val = await response.Content.ReadAsStringAsync();

            var jObj     = (JObject)JsonConvert.DeserializeObject(val);
            var services = jObj["CheckCapacitySummaryResult"];
            var results  = services.ToObject <List <Models.Models.Web.FromExternalServices.DosService> >();

            if (!_filterServicesFeature.IsEnabled && !filterServices)
            {
                return(BuildResponseMessage(results));
            }

            var serviceAvailability = _serviceAvailabilityManager.FindServiceAvailability(dosFilteredCase);

            return(BuildResponseMessage(serviceAvailability.Filter(results)));
        }
        public async Task <HttpResponseMessage> GetFilteredServices(HttpRequestMessage request, bool filterServices, DosEndpoint?endpoint)
        {
            var content = await request.Content.ReadAsStringAsync();

            var dosCase = GetObjectFromRequest <DosCase>(content);

            dosCase.SearchDistance = _configuration.DoSSearchDistance;

            var dosCaseRequest   = BuildRequestMessage(dosCase);
            var originalPostcode = dosCase.PostCode;

            var response = await _dosService.GetServices(dosCaseRequest, endpoint);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                return(response);
            }

            var dosFilteredCase = GetObjectFromRequest <DosFilteredCase>(content);

            var val = await response.Content.ReadAsStringAsync();

            var jObj     = (JObject)JsonConvert.DeserializeObject(val);
            var services = jObj["CheckCapacitySummaryResult"];
            var results  = services.ToObject <List <Models.Models.Business.DosService> >();


            var filteredByServiceWhitelistResults = await _serviceWhitelistFilter.Filter(results, originalPostcode);

            var mappedByServiceTypeResults = await _serviceTypeMapper.Map(filteredByServiceWhitelistResults, originalPostcode);

            var filteredByUnknownTypeResults = _serviceTypeFilter.FilterUnknownTypes(mappedByServiceTypeResults);

            if (!_filterServicesFeature.IsEnabled && !filterServices)
            {
                return(BuildResponseMessage(filteredByUnknownTypeResults));
            }
            var filteredByclosedCallbackTypeResults = _serviceTypeFilter.FilterClosedCallbackServices(filteredByUnknownTypeResults);
            var serviceAvailability = _serviceAvailabilityManager.FindServiceAvailability(dosFilteredCase);

            return(BuildResponseMessage(serviceAvailability.Filter(filteredByclosedCallbackTypeResults)));
        }