public async Task <IActionResult> GetParcelV2( [FromRoute] string objectId, [FromServices] IActionContextAccessor actionContextAccessor, [FromHeader(Name = HeaderNames.IfNoneMatch)] string ifNoneMatch, [FromServices] IsParcelOsloApiEnabledToggle featureToggle, CancellationToken cancellationToken = default) { if (!featureToggle.FeatureEnabled) { return(NotFound()); } var contentFormat = DetermineFormat(actionContextAccessor.ActionContext); RestRequest BackendRequest() => CreateBackendDetailRequest(objectId); var cacheKey = $"oslo/parcel:{objectId}"; var value = await(CacheToggle.FeatureEnabled ? GetFromCacheThenFromBackendAsync( contentFormat.ContentType, BackendRequest, cacheKey, CreateDefaultHandleBadRequest(), cancellationToken) : GetFromBackendAsync( contentFormat.ContentType, BackendRequest, CreateDefaultHandleBadRequest(), cancellationToken)); return(new BackendResponseResult(value)); }
public async Task <IActionResult> ListParcelsV2( [FromQuery] int?offset, [FromQuery] int?limit, [FromQuery] string sort, [FromQuery] string status, [FromServices] IActionContextAccessor actionContextAccessor, [FromServices] IOptions <ParcelOptionsV2> responseOptions, [FromHeader(Name = HeaderNames.IfNoneMatch)] string ifNoneMatch, [FromServices] IsParcelOsloApiEnabledToggle 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, status); var cacheKey = CreateCacheKeyForRequestQuery($"oslo/parcel-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)); }
public async Task <IActionResult> CountParcelsV2( [FromServices] IActionContextAccessor actionContextAccessor, [FromHeader(Name = HeaderNames.IfNoneMatch)] string ifNoneMatch, [FromServices] IsParcelOsloApiEnabledToggle featureToggle, CancellationToken cancellationToken = default) { if (!featureToggle.FeatureEnabled) { return(NotFound()); } var contentFormat = DetermineFormat(actionContextAccessor.ActionContext); IRestRequest BackendRequest() => CreateBackendCountRequest(); return(new BackendResponseResult( await GetFromBackendAsync( contentFormat.ContentType, BackendRequest, CreateDefaultHandleBadRequest(), cancellationToken))); }