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