-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
114 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
src/Public.Api/BuildingUnit/BackOffice/BuildingUnitBackOfficerController-Move.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
namespace Public.Api.BuildingUnit.BackOffice | ||
{ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Be.Vlaanderen.Basisregisters.Api.Exceptions; | ||
using BuildingRegistry.Api.BackOffice.Abstractions.BuildingUnit.Requests; | ||
using BuildingRegistry.Api.Oslo.BuildingUnit.Detail; | ||
using Common.Infrastructure; | ||
using Common.Infrastructure.Extensions; | ||
using Infrastructure; | ||
using Infrastructure.Swagger; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.Infrastructure; | ||
using RestSharp; | ||
using Swashbuckle.AspNetCore.Annotations; | ||
using Swashbuckle.AspNetCore.Filters; | ||
using ProblemDetails = Be.Vlaanderen.Basisregisters.BasicApiProblem.ProblemDetails; | ||
using ValidationProblemDetails = Be.Vlaanderen.Basisregisters.BasicApiProblem.ValidationProblemDetails; | ||
|
||
public partial class BuildingUnitBackOfficeController | ||
{ | ||
public const string MoveBuildingUnitRoute = "gebouweenheden/{objectId}/acties/verplaatsen"; | ||
|
||
/// <summary> | ||
/// Verplaats de gebouweenheid naar het doelgebouw (v2). | ||
/// </summary> | ||
/// <param name="objectId">Identificator van de gebouweenheid.</param> | ||
/// <param name="moveBuildingUnitRequest"></param> | ||
/// <param name="actionContextAccessor"></param> | ||
/// <param name="problemDetailsHelper"></param> | ||
/// <param name="moveBuildingUnitToggle"></param> | ||
/// <param name="ifMatch">If-Match header met ETag van de laatst gekende versie van de gebouweenheid (optioneel).</param> | ||
/// <param name="cancellationToken"></param> | ||
/// <response code="202">Als het ticket succesvol is aangemaakt.</response> | ||
/// <response code="400">Als uw verzoek foutieve data bevat.</response> | ||
/// <response code="401">Als u niet geauthenticeerd bent om deze actie uit te voeren.</response> | ||
/// <response code="403">Als u niet beschikt over de correcte rechten om deze actie uit te voeren.</response> | ||
/// <response code="404">Als de gebouweenheid niet gevonden kan worden.</response> | ||
/// <response code="406">Als het gevraagde formaat niet beschikbaar is.</response> | ||
/// <response code="412">Als de If-Match header niet overeenkomt met de laatste ETag.</response> | ||
/// <response code="429">Als het aantal requests per seconde de limiet overschreven heeft.</response> | ||
/// <response code="500">Als er een interne fout is opgetreden.</response> | ||
/// <returns></returns> | ||
[ApiOrder(ApiOrder.BuildingUnit.Edit + 20)] | ||
[ProducesResponseType(StatusCodes.Status202Accepted)] | ||
[ProducesResponseType(typeof(ValidationProblemDetails), StatusCodes.Status400BadRequest)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status401Unauthorized)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status403Forbidden)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status404NotFound)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status412PreconditionFailed)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status429TooManyRequests)] | ||
[ProducesResponseType(typeof(ProblemDetails), StatusCodes.Status500InternalServerError)] | ||
[SwaggerResponseHeader(StatusCodes.Status202Accepted, "location", "string", "De URL van het aangemaakte ticket.")] | ||
[SwaggerResponseHeader(StatusCodes.Status202Accepted, "x-correlation-id", "string", "Correlatie identificator van de response.")] | ||
[SwaggerRequestExample(typeof(MoveBuildingUnitRequest), typeof(MoveBuildingUnitRequestExamples))] | ||
[SwaggerResponseExample(StatusCodes.Status400BadRequest, typeof(BadRequestResponseExamplesV2))] | ||
[SwaggerResponseExample(StatusCodes.Status401Unauthorized, typeof(UnauthorizedOAuthResponseExamplesV2))] | ||
[SwaggerResponseExample(StatusCodes.Status403Forbidden, typeof(ForbiddenOAuthResponseExamplesV2))] | ||
[SwaggerResponseExample(StatusCodes.Status404NotFound, typeof(BuildingUnitNotFoundResponseExamples))] | ||
[SwaggerResponseExample(StatusCodes.Status412PreconditionFailed, typeof(PreconditionFailedResponseExamplesV2))] | ||
[SwaggerResponseExample(StatusCodes.Status429TooManyRequests, typeof(TooManyRequestsResponseExamplesV2))] | ||
[SwaggerResponseExample(StatusCodes.Status500InternalServerError, typeof(InternalServerErrorResponseExamplesV2))] | ||
[SwaggerOperation(Description = "Verplaats de gebouweenheid naar het doelgebouw.")] | ||
[HttpPost(MoveBuildingUnitRoute, Name = nameof(MoveBuildingUnit))] | ||
public async Task<IActionResult> MoveBuildingUnit( | ||
[FromRoute] int objectId, | ||
[FromBody] MoveBuildingUnitRequest moveBuildingUnitRequest, | ||
[FromServices] IActionContextAccessor actionContextAccessor, | ||
[FromServices] ProblemDetailsHelper problemDetailsHelper, | ||
[FromServices] MoveBuildingUnitToggle moveBuildingUnitToggle, | ||
[FromHeader(Name = HeaderNames.IfMatch)] string? ifMatch, | ||
CancellationToken cancellationToken = default) | ||
{ | ||
if (!moveBuildingUnitToggle.FeatureEnabled) | ||
{ | ||
return NotFound(); | ||
} | ||
|
||
var contentFormat = DetermineFormat(actionContextAccessor.ActionContext); | ||
|
||
RestRequest BackendRequest() => | ||
CreateBackendRequestWithJsonBody(MoveBuildingUnitRoute, moveBuildingUnitRequest, Method.Post) | ||
.AddParameter("objectId", objectId, ParameterType.UrlSegment) | ||
.AddHeaderIfMatch(ifMatch) | ||
.AddHeaderAuthorization(actionContextAccessor); | ||
|
||
var value = await GetFromBackendWithBadRequestAsync( | ||
contentFormat.ContentType, | ||
BackendRequest, | ||
CreateDefaultHandleBadRequest(), | ||
problemDetailsHelper, | ||
cancellationToken: cancellationToken); | ||
|
||
return new BackendResponseResult(value, BackendResponseResultOptions.ForBackOffice()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters