Ejemplo n.º 1
0
        public async Task <IActionResult> CountAddressesV2(
            [FromQuery] string gemeentenaam,
            [FromQuery] int?postcode,
            [FromQuery] string straatnaam,
            [FromQuery] string homoniemToevoeging,
            [FromQuery] string huisnummer,
            [FromQuery] string busnummer,
            [FromServices] IActionContextAccessor actionContextAccessor,
            [FromHeader(Name = HeaderNames.IfNoneMatch)] string ifNoneMatch,
            [FromServices] IsAddressOsloApiEnabledToggle featureToggle,
            CancellationToken cancellationToken = default)
        {
            if (!featureToggle.FeatureEnabled)
            {
                return(NotFound());
            }

            var contentFormat = DetermineFormat(actionContextAccessor.ActionContext);

            IRestRequest BackendRequest() => CreateBackendCountRequest(
                busnummer,
                huisnummer,
                postcode,
                gemeentenaam,
                straatnaam,
                homoniemToevoeging);

            return(new BackendResponseResult(
                       await GetFromBackendAsync(
                           contentFormat.ContentType,
                           BackendRequest,
                           CreateDefaultHandleBadRequest(),
                           cancellationToken)));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> GetAddressV2(
            [FromRoute] int objectId,
            [FromServices] IActionContextAccessor actionContextAccessor,
            [FromHeader(Name = HeaderNames.IfNoneMatch)] string ifNoneMatch,
            [FromServices] IsAddressOsloApiEnabledToggle featureToggle,
            CancellationToken cancellationToken = default)
        {
            if (!featureToggle.FeatureEnabled)
            {
                return(NotFound());
            }

            var contentFormat = DetermineFormat(actionContextAccessor.ActionContext);

            RestRequest BackendRequest() => CreateBackendDetailRequest(objectId);

            var cacheKey = $"oslo/address:{objectId}";

            var value = await(CacheToggle.FeatureEnabled
                ? GetFromCacheThenFromBackendAsync(
                                  contentFormat.ContentType,
                                  BackendRequest,
                                  cacheKey,
                                  CreateDefaultHandleBadRequest(),
                                  cancellationToken)
                : GetFromBackendAsync(
                                  contentFormat.ContentType,
                                  BackendRequest,
                                  CreateDefaultHandleBadRequest(),
                                  cancellationToken));

            return(new BackendResponseResult(value));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> ListAddressesV2(
            [FromQuery] int?offset,
            [FromQuery] int?limit,
            [FromQuery] string sort,
            [FromQuery] string gemeentenaam,
            [FromQuery] int?postcode,
            [FromQuery] string straatnaam,
            [FromQuery] string homoniemToevoeging,
            [FromQuery] string huisnummer,
            [FromQuery] string busnummer,
            [FromQuery] string niscode,
            [FromQuery] string status,
            [FromServices] IActionContextAccessor actionContextAccessor,
            [FromServices] IOptions <AddressOptionsV2> responseOptions,
            [FromHeader(Name = HeaderNames.IfNoneMatch)] string ifNoneMatch,
            [FromServices] IsAddressOsloApiEnabledToggle featureToggle,
            CancellationToken cancellationToken = default)
        {
            if (!featureToggle.FeatureEnabled)
            {
                return(NotFound());
            }

            var        contentFormat = DetermineFormat(actionContextAccessor.ActionContext);
            const Taal taal          = Taal.NL;

            IRestRequest BackendRequest() => CreateBackendListRequest(
                offset,
                limit,
                taal,
                sort,
                busnummer,
                huisnummer,
                postcode,
                gemeentenaam,
                straatnaam,
                homoniemToevoeging,
                niscode,
                status);

            var cacheKey = CreateCacheKeyForRequestQuery($"oslo/address-list:{taal}");

            var value = await(CacheToggle.FeatureEnabled
                ? GetFromCacheThenFromBackendAsync(
                                  contentFormat.ContentType,
                                  BackendRequest,
                                  cacheKey,
                                  CreateDefaultHandleBadRequest(),
                                  cancellationToken)
                : GetFromBackendAsync(
                                  contentFormat.ContentType,
                                  BackendRequest,
                                  CreateDefaultHandleBadRequest(),
                                  cancellationToken));

            return(BackendListResponseResult.Create(value, Request.Query, responseOptions.Value.VolgendeUrl));
        }