-
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.
Add Address fields onto v3 trn request (#1696)
- Loading branch information
Showing
11 changed files
with
300 additions
and
10 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
19 changes: 19 additions & 0 deletions
19
TeachingRecordSystem/src/TeachingRecordSystem.Api/V3/Core/SharedModels/Gender.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,19 @@ | ||
using TeachingRecordSystem.Core.Dqt.Models; | ||
|
||
namespace TeachingRecordSystem.Api.V3.Core.SharedModels; | ||
|
||
public enum Gender | ||
{ | ||
Male = 1, | ||
Female = 2, | ||
Other = 3 | ||
} | ||
|
||
public static class GenderExtensions | ||
{ | ||
public static Contact_GenderCode ConvertToContact_GenderCode(this Gender input) => | ||
input.ConvertToEnumByValue<Gender, Contact_GenderCode>(); | ||
|
||
public static bool TryConvertToContact_GenderCode(this Gender input, out Contact_GenderCode result) => | ||
input.TryConvertToEnumByValue(out result); | ||
} |
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
24 changes: 23 additions & 1 deletion
24
...ingRecordSystem/src/TeachingRecordSystem.Api/V3/VNext/Requests/CreateTrnRequestRequest.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,8 +1,30 @@ | ||
|
||
using TeachingRecordSystem.Api.V3.Core.SharedModels; | ||
|
||
namespace TeachingRecordSystem.Api.V3.VNext.Requests; | ||
|
||
[GenerateVersionedDto(typeof(V20240606.Requests.CreateTrnRequestRequest))] | ||
[GenerateVersionedDto(typeof(V20240606.Requests.CreateTrnRequestRequest), excludeMembers: "Person")] | ||
public partial record CreateTrnRequestRequest | ||
{ | ||
public bool IdentityVerified { get; init; } | ||
public string? OneLoginUserSubject { get; init; } | ||
public required CreateTrnRequestRequestPerson Person { get; init; } | ||
} | ||
|
||
[GenerateVersionedDto(typeof(V20240606.Requests.CreateTrnRequestRequestPerson))] | ||
public partial record CreateTrnRequestRequestPerson | ||
{ | ||
public CreateTrnRequestAddress? Address { get; init; } | ||
public Gender? GenderCode { get; init; } | ||
} | ||
|
||
public class CreateTrnRequestAddress | ||
{ | ||
public string? AddressLine1 { get; init; } | ||
public string? AddressLine2 { get; init; } | ||
public string? AddressLine3 { get; init; } | ||
public string? City { get; init; } | ||
public string? Postcode { get; init; } | ||
public string? Country { get; init; } | ||
} | ||
|
40 changes: 40 additions & 0 deletions
40
...stem/src/TeachingRecordSystem.Api/V3/VNext/Validators/CreateTrnRequestRequestValidator.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,40 @@ | ||
using FluentValidation; | ||
using TeachingRecordSystem.Api.V3.VNext.Requests; | ||
using TeachingRecordSystem.Core.Dqt.Models; | ||
|
||
namespace TeachingRecordSystem.Api.V3.VNext.Validators; | ||
|
||
public class CreateTrnRequestRequestValidator : AbstractValidator<CreateTrnRequestRequest> | ||
{ | ||
public CreateTrnRequestRequestValidator(IClock clock) | ||
{ | ||
RuleFor(r => r.Person.Address!.AddressLine1) | ||
.MaximumLength(AttributeConstraints.Contact.Address1_Line1MaxLength) | ||
.When(r => r.Person.Address != null); | ||
|
||
RuleFor(r => r.Person.Address!.AddressLine2) | ||
.MaximumLength(AttributeConstraints.Contact.Address1_Line2MaxLength) | ||
.When(r => r.Person.Address != null); | ||
|
||
RuleFor(r => r.Person.Address!.AddressLine3) | ||
.MaximumLength(AttributeConstraints.Contact.Address1_Line3MaxLength) | ||
.When(r => r.Person.Address != null); | ||
|
||
RuleFor(r => r.Person.Address!.City) | ||
.MaximumLength(AttributeConstraints.Contact.Address1_CityMaxLength) | ||
.When(r => r.Person.Address != null); | ||
|
||
RuleFor(r => r.Person.Address!.Country) | ||
.MaximumLength(AttributeConstraints.Contact.Address1_CountryMaxLength) | ||
.When(r => r.Person.Address != null); | ||
|
||
RuleFor(r => r.Person.Address!.Postcode) | ||
.MaximumLength(AttributeConstraints.Contact.Address1_PostalCodeLength) | ||
.When(r => r.Person.Address != null); | ||
|
||
RuleFor(r => r.Person.GenderCode) | ||
.IsInEnum(); | ||
} | ||
} | ||
|
||
|
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
Oops, something went wrong.