|
15 | 15 | using System; |
16 | 16 | using Prime.Models; |
17 | 17 | using Prime.Models.Api; |
| 18 | +using Microsoft.AspNetCore.Http.HttpResults; |
18 | 19 |
|
19 | 20 | namespace Prime.Controllers |
20 | 21 | { |
@@ -375,6 +376,58 @@ public async Task<ActionResult> CreateOrUpdateOgranizationAgreement(int healthAu |
375 | 376 | return Ok(document); ; |
376 | 377 | } |
377 | 378 |
|
| 379 | + // PUT: api/health-authorities/1/additional-document |
| 380 | + /// <summary> |
| 381 | + /// Create or Update health auth organization agreement |
| 382 | + /// </summary> |
| 383 | + /// <param name="healthAuthorityId"></param> |
| 384 | + /// <param name="documentGuid"></param> |
| 385 | + [HttpPut("{healthAuthorityId}/additional-document", Name = nameof(CreateAdditionalDocument))] |
| 386 | + [Authorize(Roles = Roles.PrimeMaintenance)] |
| 387 | + [ProducesResponseType(typeof(ApiMessageResponse), StatusCodes.Status400BadRequest)] |
| 388 | + [ProducesResponseType(StatusCodes.Status401Unauthorized)] |
| 389 | + [ProducesResponseType(StatusCodes.Status403Forbidden)] |
| 390 | + [ProducesResponseType(typeof(ApiMessageResponse), StatusCodes.Status404NotFound)] |
| 391 | + [ProducesResponseType(typeof(ApiResultResponse<HealthAuthorityOrganizationAgreementDocument>), StatusCodes.Status200OK)] |
| 392 | + public async Task<ActionResult> CreateAdditionalDocument(int healthAuthorityId, [FromQuery] Guid documentGuid) |
| 393 | + { |
| 394 | + if (!await _healthAuthorityService.HealthAuthorityExistsAsync(healthAuthorityId)) |
| 395 | + { |
| 396 | + return NotFound($"Health Authority not found with id {healthAuthorityId}"); |
| 397 | + } |
| 398 | + |
| 399 | + var document = await _healthAuthorityService.CreateAdditionalDocumentAsync(healthAuthorityId, documentGuid); |
| 400 | + if (document == null) |
| 401 | + { |
| 402 | + return BadRequest("Additional Document could not be created; network error or upload is already submitted"); |
| 403 | + } |
| 404 | + |
| 405 | + return Ok(document); |
| 406 | + } |
| 407 | + |
| 408 | + // DELETE: api/health-authorities/1/additional-document |
| 409 | + /// <summary> |
| 410 | + /// Create or Update health auth organization agreement |
| 411 | + /// </summary> |
| 412 | + /// <param name="healthAuthorityId"></param> |
| 413 | + /// <param name="documentGuid"></param> |
| 414 | + [HttpDelete("{healthAuthorityId}/additional-document", Name = nameof(DeleteAdditionalDocument))] |
| 415 | + [Authorize(Roles = Roles.PrimeMaintenance)] |
| 416 | + [ProducesResponseType(StatusCodes.Status401Unauthorized)] |
| 417 | + [ProducesResponseType(StatusCodes.Status403Forbidden)] |
| 418 | + [ProducesResponseType(StatusCodes.Status204NoContent)] |
| 419 | + public async Task<ActionResult> DeleteAdditionalDocument(int healthAuthorityId, [FromQuery] Guid documentGuid) |
| 420 | + { |
| 421 | + if (!await _healthAuthorityService.HealthAuthorityExistsAsync(healthAuthorityId)) |
| 422 | + { |
| 423 | + return NotFound($"Health Authority not found with id {healthAuthorityId}"); |
| 424 | + } |
| 425 | + |
| 426 | + await _healthAuthorityService.DeleteAdditionalDocumentAsync(healthAuthorityId, documentGuid); |
| 427 | + |
| 428 | + return NoContent(); |
| 429 | + } |
| 430 | + |
378 | 431 | // GET: api/health-authorities/1/organization-agreement/token |
379 | 432 | /// <summary> |
380 | 433 | /// Gets a download token for the latest organization agreement for a health authority. |
|
0 commit comments