-
Notifications
You must be signed in to change notification settings - Fork 0
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
10 changed files
with
136 additions
and
116 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
52 changes: 52 additions & 0 deletions
52
...ngRecordSystem/src/TeachingRecordSystem.Api/V3/V20240416/Controllers/TeacherController.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,52 @@ | ||
using System.Security.Claims; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Swashbuckle.AspNetCore.Annotations; | ||
using TeachingRecordSystem.Api.Infrastructure.ModelBinding; | ||
using TeachingRecordSystem.Api.Infrastructure.Security; | ||
using TeachingRecordSystem.Api.V3.Core.Operations; | ||
using TeachingRecordSystem.Api.V3.V20240416.Requests; | ||
using TeachingRecordSystem.Api.V3.V20240416.Responses; | ||
|
||
namespace TeachingRecordSystem.Api.V3.V20240416.Controllers; | ||
|
||
[Route("teacher")] | ||
public class TeacherController(IMapper mapper) : ControllerBase | ||
{ | ||
[Authorize(AuthorizationPolicies.IdentityUserWithTrn)] | ||
[HttpGet] | ||
[SwaggerOperation( | ||
OperationId = "GetCurrentTeacher", | ||
Summary = "Get the current teacher's details", | ||
Description = "Gets the details for the authenticated teacher.")] | ||
[ProducesResponseType(typeof(GetTeacherResponse), StatusCodes.Status200OK)] | ||
[ProducesResponseType(typeof(void), StatusCodes.Status403Forbidden)] | ||
public async Task<IActionResult> Get( | ||
[FromQuery, ModelBinder(typeof(FlagsEnumStringListModelBinder)), SwaggerParameter("The additional properties to include in the response.")] GetTeacherRequestIncludes? include, | ||
[FromServices] GetPersonHandler handler) | ||
{ | ||
var trn = User.FindFirstValue("trn"); | ||
|
||
if (trn is null) | ||
{ | ||
return MissingOrInvalidTrn(); | ||
} | ||
|
||
var command = new GetPersonCommand( | ||
trn, | ||
include is not null ? (GetPersonCommandIncludes)include : GetPersonCommandIncludes.None, | ||
DateOfBirth: null); | ||
|
||
var result = await handler.Handle(command); | ||
|
||
if (result is null) | ||
{ | ||
return MissingOrInvalidTrn(); | ||
} | ||
|
||
var response = mapper.Map<GetTeacherResponse>(result); | ||
return Ok(response); | ||
|
||
IActionResult MissingOrInvalidTrn() => Forbid(); | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
...ordSystem/src/TeachingRecordSystem.Api/V3/V20240416/Requests/GetTeacherRequestIncludes.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,25 @@ | ||
using System.ComponentModel; | ||
|
||
namespace TeachingRecordSystem.Api.V3.V20240416.Requests; | ||
|
||
[Flags] | ||
[Description("Comma-separated list of data to include in response.")] | ||
public enum GetTeacherRequestIncludes | ||
{ | ||
None = 0, | ||
|
||
Induction = 1 << 0, | ||
InitialTeacherTraining = 1 << 1, | ||
NpqQualifications = 1 << 2, | ||
MandatoryQualifications = 1 << 3, | ||
PendingDetailChanges = 1 << 4, | ||
HigherEducationQualifications = 1 << 5, | ||
Sanctions = 1 << 6, | ||
Alerts = 1 << 7, | ||
PreviousNames = 1 << 8, | ||
|
||
[ExcludeFromSchema] | ||
_AllowIdSignInWithProhibitions = 1 << 9, | ||
|
||
All = Induction | InitialTeacherTraining | NpqQualifications | MandatoryQualifications | PendingDetailChanges | HigherEducationQualifications | Sanctions | Alerts | PreviousNames | ||
} |
7 changes: 7 additions & 0 deletions
7
...ingRecordSystem/src/TeachingRecordSystem.Api/V3/V20240416/Responses/GetTeacherResponse.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,7 @@ | ||
using TeachingRecordSystem.Api.V3.Core.Operations; | ||
|
||
namespace TeachingRecordSystem.Api.V3.V20240416.Responses; | ||
|
||
[AutoMap(typeof(GetPersonResult))] | ||
[GenerateVersionedDto(typeof(V20240101.Responses.GetTeacherResponse))] | ||
public partial record GetTeacherResponse; |
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
4 changes: 4 additions & 0 deletions
4
...em/src/TeachingRecordSystem.Api/V3/V20240606/Responses/CreateDateOfBirthChangeResponse.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,4 @@ | ||
namespace TeachingRecordSystem.Api.V3.V20240606.Responses; | ||
|
||
[GenerateVersionedDto(typeof(V20240412.Responses.CreateDateOfBirthChangeResponse))] | ||
public partial record CreateDateOfBirthChangeResponse; |
4 changes: 4 additions & 0 deletions
4
...ordSystem/src/TeachingRecordSystem.Api/V3/V20240606/Responses/CreateNameChangeResponse.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,4 @@ | ||
namespace TeachingRecordSystem.Api.V3.V20240606.Responses; | ||
|
||
[GenerateVersionedDto(typeof(V20240412.Responses.CreateNameChangeResponse))] | ||
public partial record CreateNameChangeResponse; |
18 changes: 4 additions & 14 deletions
18
...ingRecordSystem/src/TeachingRecordSystem.Api/V3/V20240606/Responses/FindPersonResponse.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 |
---|---|---|
@@ -1,25 +1,15 @@ | ||
using TeachingRecordSystem.Api.V3.Core.Operations; | ||
using TeachingRecordSystem.Api.V3.V20240101.ApiModels; | ||
using TeachingRecordSystem.Api.V3.V20240606.Requests; | ||
|
||
namespace TeachingRecordSystem.Api.V3.V20240606.Responses; | ||
|
||
[AutoMap(typeof(FindPersonByLastNameAndDateOfBirthResult))] | ||
public record FindPersonResponse | ||
[GenerateVersionedDto(typeof(V20240101.Responses.FindTeachersResponse), excludeMembers: ["Query", "Results"])] | ||
public partial record FindPersonResponse | ||
{ | ||
public required int Total { get; init; } | ||
public required FindPersonRequest Query { get; init; } | ||
public required IReadOnlyCollection<FindPersonResponseResult> Results { get; init; } | ||
} | ||
|
||
[AutoMap(typeof(FindPersonByLastNameAndDateOfBirthResultItem))] | ||
public record FindPersonResponseResult | ||
{ | ||
public required string Trn { get; init; } | ||
public required DateOnly DateOfBirth { get; init; } | ||
public required string FirstName { get; init; } | ||
public required string MiddleName { get; init; } | ||
public required string LastName { get; init; } | ||
public required IReadOnlyCollection<SanctionInfo> Sanctions { get; init; } | ||
public required IReadOnlyCollection<NameInfo> PreviousNames { get; init; } | ||
} | ||
[GenerateVersionedDto(typeof(V20240101.Responses.FindTeachersResponseResult))] | ||
public partial record FindPersonResponseResult; |
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