public async Task <IActionResult> ApproveStreetName(
            [FromRoute] int objectId,
            [FromServices] IActionContextAccessor actionContextAccessor,
            [FromServices] ProblemDetailsHelper problemDetailsHelper,
            [FromServices] ApproveStreetNameToggle approveStreetNameToggle,
            [FromHeader(Name = HeaderNames.IfMatch)] string?ifMatch,
            CancellationToken cancellationToken = default)
        {
            if (!approveStreetNameToggle.FeatureEnabled)
            {
                return(NotFound());
            }

            var contentFormat = DetermineFormat(actionContextAccessor.ActionContext);

            IRestRequest BackendRequest() => CreateBackendPutRequest(objectId, ifMatch);

            var value = await GetFromBackendWithBadRequestAsync(
                contentFormat.ContentType,
                BackendRequest,
                CreateDefaultHandleBadRequest(),
                problemDetailsHelper,
                cancellationToken : cancellationToken);

            return(new BackendResponseResult(value, BackendResponseResultOptions.ForBackOffice()));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> PlanBuildingUnit(
            [FromBody] PlanBuildingUnitRequest planBuildingUnitRequest,
            [FromServices] IActionContextAccessor actionContextAccessor,
            [FromServices] ProblemDetailsHelper problemDetailsHelper,
            [FromServices] PlanBuildingUnitToggle planBuildingUnitToggle,
            CancellationToken cancellationToken = default)
        {
            if (!planBuildingUnitToggle.FeatureEnabled)
            {
                return(NotFound());
            }

            var contentFormat = DetermineFormat(actionContextAccessor.ActionContext);

            IRestRequest BackendRequest() => CreateBackendRequestWithJsonBody(
                "gebouweenheden/acties/plannen",
                planBuildingUnitRequest,
                Method.POST);

            var value = await GetFromBackendWithBadRequestAsync(
                contentFormat.ContentType,
                BackendRequest,
                CreateDefaultHandleBadRequest(),
                problemDetailsHelper,
                cancellationToken : cancellationToken);

            return(new BackendResponseResult(value, BackendResponseResultOptions.ForBackOffice()));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> ProposeAddress(
            [FromBody] AddressProposeRequest addressProposeRequest,
            [FromServices] IActionContextAccessor actionContextAccessor,
            [FromServices] ProblemDetailsHelper problemDetailsHelper,
            [FromServices] ProposeAddressToggle proposeAddressToggle,
            CancellationToken cancellationToken = default)
        {
            if (!proposeAddressToggle.FeatureEnabled)
            {
                return(NotFound());
            }

            var contentFormat = DetermineFormat(actionContextAccessor.ActionContext);

            IRestRequest BackendRequest() => CreateBackendRequestWithJsonBody(
                ProposeAddressRoute,
                addressProposeRequest,
                Method.POST);

            var value = await GetFromBackendWithBadRequestAsync(
                contentFormat.ContentType,
                BackendRequest,
                CreateDefaultHandleBadRequest(),
                problemDetailsHelper,
                cancellationToken : cancellationToken);

            return(new BackendResponseResult(value, BackendResponseResultOptions.ForBackOffice()));
        }
        public async Task <IActionResult> GetStreetName(
            [FromRoute] int objectId,
            [FromServices] IActionContextAccessor actionContextAccessor,
            [FromHeader(Name = HeaderNames.IfNoneMatch)] string ifNoneMatch,
            CancellationToken cancellationToken = default)
        {
            var contentFormat = DetermineFormat(actionContextAccessor.ActionContext);

            RestRequest BackendRequest() => CreateBackendDetailRequest(objectId);

            var cacheKey = $"legacy/streetname:{objectId}";

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

            return(new BackendResponseResult(value, BackendResponseResultOptions.ForRead()));
        }
        public async Task <IActionResult> CorrectPositionAddress(
            [FromRoute] int objectId,
            [FromBody] AddressCorrectPositionRequest addressCorrectPositionRequest,
            [FromServices] IActionContextAccessor actionContextAccessor,
            [FromServices] ProblemDetailsHelper problemDetailsHelper,
            [FromServices] CorrectPositionAddressToggle correctPositionAddressToggleToggle,
            [FromHeader(Name = HeaderNames.IfMatch)] string?ifMatch,
            CancellationToken cancellationToken = default)
        {
            if (!correctPositionAddressToggleToggle.FeatureEnabled)
            {
                return(NotFound());
            }

            var contentFormat = DetermineFormat(actionContextAccessor.ActionContext);

            IRestRequest BackendRequest()
            {
                var request = new RestRequest(CorrectPositionRoute, Method.POST)
                              .AddParameter(
                    "application/json; charset=utf-8",
                    JsonConvert.SerializeObject(addressCorrectPositionRequest),
                    ParameterType.RequestBody)
                              .AddParameter(
                    "objectId",
                    objectId,
                    ParameterType.UrlSegment);

                if (ifMatch is not null)
                {
                    request.AddHeader(HeaderNames.IfMatch, ifMatch);
                }

                return(request);
            }

            var value = await GetFromBackendWithBadRequestAsync(
                contentFormat.ContentType,
                BackendRequest,
                CreateDefaultHandleBadRequest(),
                problemDetailsHelper,
                cancellationToken : cancellationToken);

            return(new BackendResponseResult(value, BackendResponseResultOptions.ForBackOffice()));
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> GetStatus(
            [FromRoute] string uploadId,
            [FromServices] ProblemDetailsHelper problemDetailsHelper,
            CancellationToken cancellationToken = default)
        {
            var response = await GetFromBackendWithBadRequestAsync(
                AcceptType.Json,
                () => CreateBackendUploadStatusRequest(uploadId),
                CreateDefaultHandleBadRequest(),
                problemDetailsHelper,
                cancellationToken : cancellationToken);

            var options = new BackendResponseResultOptions
            {
                ForwardHeaders = new[] { "Retry-After" }
            };

            return(response.ToActionResult(options));
        }
Ejemplo n.º 7
0
        public async Task <IActionResult> GetTickets(
            [FromServices] IActionContextAccessor actionContextAccessor,
            CancellationToken cancellationToken = default)
        {
            if (actionContextAccessor.ActionContext == null)
            {
                return(BadRequest());
            }

            var contentFormat = DetermineFormat(actionContextAccessor.ActionContext);

            RestRequest BackendRequest() => CreateBackendGetAllRequest();

            var value = await GetFromBackendAsync(
                contentFormat.ContentType,
                BackendRequest,
                CreateDefaultHandleBadRequest(),
                cancellationToken);

            return(new BackendResponseResult(value, BackendResponseResultOptions.ForRead()));
        }
Ejemplo n.º 8
0
        public async Task <IActionResult> NotRealizeBuildingUnit(
            [FromRoute] int objectId,
            [FromServices] IActionContextAccessor actionContextAccessor,
            [FromServices] ProblemDetailsHelper problemDetailsHelper,
            [FromServices] RealizeBuildingUnitToggle notRealizeBuildingUnitToggle,
            [FromHeader(Name = HeaderNames.IfMatch)] string?ifMatch,
            CancellationToken cancellationToken = default)
        {
            if (!notRealizeBuildingUnitToggle.FeatureEnabled)
            {
                return(NotFound());
            }

            var contentFormat = DetermineFormat(actionContextAccessor.ActionContext);

            IRestRequest BackendRequest()
            {
                var request = new RestRequest("gebouweenheden/{persistentLocalId}/acties/nietrealiseren", Method.POST);

                request.AddParameter("persistentLocalId", objectId, ParameterType.UrlSegment);

                if (ifMatch is not null)
                {
                    request.AddHeader(HeaderNames.IfMatch, ifMatch);
                }

                return(request);
            }

            var value = await GetFromBackendWithBadRequestAsync(
                contentFormat.ContentType,
                BackendRequest,
                CreateDefaultHandleBadRequest(),
                problemDetailsHelper,
                cancellationToken : cancellationToken);

            return(new BackendResponseResult(value, BackendResponseResultOptions.ForBackOffice()));
        }