From 839abf7cfe3d42273a00a601308161b46fbc9f61 Mon Sep 17 00:00:00 2001 From: VS Date: Wed, 18 Sep 2024 12:06:13 +0100 Subject: [PATCH 01/27] Updated Participant screen Actions menu to shows Add Consent and Add RTW when Enrolment status is Enrolling and Approved --- .../Pages/Participants/Components/ParticipantActionMenu.razor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Server.UI/Pages/Participants/Components/ParticipantActionMenu.razor b/src/Server.UI/Pages/Participants/Components/ParticipantActionMenu.razor index 0c4323d2..e6f8c191 100644 --- a/src/Server.UI/Pages/Participants/Components/ParticipantActionMenu.razor +++ b/src/Server.UI/Pages/Participants/Components/ParticipantActionMenu.razor @@ -31,11 +31,11 @@ Submit to Provider QA } - @if (Participant.EnrolmentStatus == EnrolmentStatus.EnrollingStatus) + @if (Participant.EnrolmentStatus == EnrolmentStatus.EnrollingStatus || Participant.EnrolmentStatus == EnrolmentStatus.ApprovedStatus) { @ConstantString.AddRightToWork } - @if (Participant.EnrolmentStatus == EnrolmentStatus.EnrollingStatus) + @if (Participant.EnrolmentStatus == EnrolmentStatus.EnrollingStatus || Participant.EnrolmentStatus == EnrolmentStatus.ApprovedStatus) { @ConstantString.AddConsent } From 27bffcf90cc374aaae95b4530f20c1d56e2ced6b Mon Sep 17 00:00:00 2001 From: PaulCooperWorkJustice Date: Wed, 18 Sep 2024 13:55:23 +0100 Subject: [PATCH 02/27] Following changes: 1. document database not populated when AWS upload fails 2. Stop loading mulitple consent files when next pressed mulitple times. 3. Able to upload a new consent document if still on page and not saved current one and left tab 4. If AWS upload fails, now get an error message saying theres been a problem. --- .../Participants/Commands/AddConsent.cs | 20 ++++++++----- .../Participants/Commands/AddRightToWork.cs | 24 +++++++-------- src/Infrastructure/Services/UploadService.cs | 30 ++++++++++--------- .../Pages/Enrolments/Components/Consent.razor | 23 ++++++++------ .../Enrolments/Components/RightToWork.razor | 1 + 5 files changed, 54 insertions(+), 44 deletions(-) diff --git a/src/Application/Features/Participants/Commands/AddConsent.cs b/src/Application/Features/Participants/Commands/AddConsent.cs index 8db8e0c6..2bdcaa46 100644 --- a/src/Application/Features/Participants/Commands/AddConsent.cs +++ b/src/Application/Features/Participants/Commands/AddConsent.cs @@ -41,8 +41,8 @@ public async Task> Handle(Command request, CancellationToken canc } var document = Document.Create(request.Document!.Name, - $"Consent form for {request.ParticipantId}", - DocumentType.PDF); + $"Consent form for {request.ParticipantId}", + DocumentType.PDF); long maxSizeBytes = Convert.ToInt64(ByteSize.FromMegabytes(Infrastructure.Constants.Documents.Consent.MaximumSizeInMegabytes).Bytes); await using var stream = request.Document.OpenReadStream(maxSizeBytes); @@ -53,12 +53,16 @@ public async Task> Handle(Command request, CancellationToken canc var result = await uploadService.UploadAsync($"{request.ParticipantId}/consent", uploadRequest); - document.SetURL(result); - document.SetVersion(request.DocumentVersion!); + if (result.Succeeded) + { + document.SetURL(result); + document.SetVersion(request.DocumentVersion!); + + participant.AddConsent(request.ConsentDate!.Value, document.Id); + + await unitOfWork.DbContext.Documents.AddAsync(document); + } - participant.AddConsent(request.ConsentDate!.Value, document.Id); - - unitOfWork.DbContext.Documents.Add(document); return result; } } @@ -135,4 +139,4 @@ private async Task BePdfFile(IBrowserFile? file, CancellationToken cancell } } } -} +} \ No newline at end of file diff --git a/src/Application/Features/Participants/Commands/AddRightToWork.cs b/src/Application/Features/Participants/Commands/AddRightToWork.cs index 7d422b9f..72eb37ff 100644 --- a/src/Application/Features/Participants/Commands/AddRightToWork.cs +++ b/src/Application/Features/Participants/Commands/AddRightToWork.cs @@ -2,10 +2,8 @@ using Cfo.Cats.Application.Common.Validators; using Cfo.Cats.Application.SecurityConstants; using Cfo.Cats.Domain.Entities.Documents; -using FluentValidation; using Humanizer.Bytes; using Microsoft.AspNetCore.Components.Forms; -using System.IO; namespace Cfo.Cats.Application.Features.Participants.Commands; @@ -35,7 +33,6 @@ public class Command : IRequest> public class Handler(IUnitOfWork unitOfWork, IUploadService uploadService) : IRequestHandler> { - public async Task> Handle(Command request, CancellationToken cancellationToken) { var participant = await unitOfWork.DbContext.Participants.FindAsync(request.ParticipantId); @@ -57,17 +54,19 @@ public async Task> Handle(Command request, CancellationToken canc var uploadRequest = new UploadRequest(request.Document.Name, UploadType.Document, memoryStream.ToArray()); var result = await uploadService.UploadAsync($"{request.ParticipantId}/rtw", uploadRequest); - - document.SetURL(result); - - if(request.IndefiniteRightToWork) + if (result.Succeeded) { - request.ValidTo = DateTime.MaxValue; - } + document.SetURL(result); - participant.AddRightToWork(request.ValidFrom!.Value, request.ValidTo!.Value, document.Id); + if (request.IndefiniteRightToWork) + { + request.ValidTo = DateTime.MaxValue; + } + + participant.AddRightToWork(request.ValidFrom!.Value, request.ValidTo!.Value, document.Id); - unitOfWork.DbContext.Documents.Add(document); + unitOfWork.DbContext.Documents.Add(document); + } return result; } } @@ -145,6 +144,5 @@ private async Task BePdfFile(IBrowserFile? file, CancellationToken cancell return header == "%PDF"; } } - } -} +} \ No newline at end of file diff --git a/src/Infrastructure/Services/UploadService.cs b/src/Infrastructure/Services/UploadService.cs index 9e2d066f..7d7083eb 100644 --- a/src/Infrastructure/Services/UploadService.cs +++ b/src/Infrastructure/Services/UploadService.cs @@ -46,18 +46,25 @@ public async Task> UploadAsync(string folder, UploadRequest uploa }; _logger.LogDebug("Uploading to S3 bucket"); - var result = await _client.PutObjectAsync(putRequest); - if (result.HttpStatusCode == HttpStatusCode.OK) - { - return putRequest.Key; - } - return Result.Failure(result.HttpStatusCode.ToString()); - } + + var result = await _client.PutObjectAsync(putRequest); + if (result.HttpStatusCode == HttpStatusCode.OK) + { + return putRequest.Key; + } + return Result.Failure(result.HttpStatusCode.ToString()); + + } catch (AmazonS3Exception s3Ex) { _logger.LogError(s3Ex, $"Error uploading file" ); return Result.Failure(s3Ex.Message); } + catch (Exception ex) + { + _logger.LogError(ex.Message, $"Error uploading file"); + return Result.Failure(ex.Message); + } } } public async Task> DownloadAsync(string key) @@ -83,9 +90,7 @@ public async Task> DownloadAsync(string key) { BucketName = _bucketName, Key = key - }; - - + }; using var response = await _client.GetObjectAsync(getRequest) .ConfigureAwait(false); @@ -95,9 +100,7 @@ public async Task> DownloadAsync(string key) return Result.Success(stream); } - - return Result.Failure("Could not download file"); - + return Result.Failure("Could not download file"); } private static Dictionary CreateScopeInformation(string folder, UploadRequest uploadRequest) @@ -116,5 +119,4 @@ private static Dictionary CreateScopeInformation(string folder, }; return scopeInfo; } - } \ No newline at end of file diff --git a/src/Server.UI/Pages/Enrolments/Components/Consent.razor b/src/Server.UI/Pages/Enrolments/Components/Consent.razor index 2172a271..e7aeb430 100644 --- a/src/Server.UI/Pages/Enrolments/Components/Consent.razor +++ b/src/Server.UI/Pages/Enrolments/Components/Consent.razor @@ -39,14 +39,14 @@ For="() => Model.Document" MaximumFileCount="1" Accept=".pdf"> - - @if (Model.Document == null || consentUploaded) - { + + @if(!consentUploaded) + { + StartIcon="@Icons.Material.Filled.Upload"> + @if (_uploading) { @ConstantString.Uploading @@ -56,14 +56,13 @@ @ConstantString.Upload } - } + }
@if (@Model.Document==null) { - No Files - + No Files } else { @@ -107,11 +106,14 @@ private bool consentUploaded; + //Guard for mulitple next clicks + private bool uploadingFile; + public async Task Validate() { try { - if (ConsentDto is not null && ConsentDto.Length > 0 || consentUploaded) + if (ConsentDto is not null && ConsentDto.Length > 0 || consentUploaded || uploadingFile) { return true; } @@ -120,6 +122,7 @@ if (form.IsValid) { + uploadingFile = true; var result = await GetNewMediator().Send(Model); if (result.Succeeded) @@ -130,6 +133,8 @@ else { Snackbar.Add($"Error uploading consent {result.ErrorMessage}", Severity.Error); + uploadingFile = false; + return false; } } diff --git a/src/Server.UI/Pages/Enrolments/Components/RightToWork.razor b/src/Server.UI/Pages/Enrolments/Components/RightToWork.razor index b93e9564..2afd0520 100644 --- a/src/Server.UI/Pages/Enrolments/Components/RightToWork.razor +++ b/src/Server.UI/Pages/Enrolments/Components/RightToWork.razor @@ -142,6 +142,7 @@ else { Snackbar.Add($"Error uploading Right to work evidence: {result.ErrorMessage}", Severity.Error); + return false; } } From a0f7a93a6fc59ded2673c294c42679a46d18de41 Mon Sep 17 00:00:00 2001 From: Carl Sixsmith Date: Mon, 23 Sep 2024 14:45:05 +0100 Subject: [PATCH 03/27] Update UploadService.cs No need for seperate catch --- src/Infrastructure/Services/UploadService.cs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Infrastructure/Services/UploadService.cs b/src/Infrastructure/Services/UploadService.cs index 7d7083eb..07bb8d81 100644 --- a/src/Infrastructure/Services/UploadService.cs +++ b/src/Infrastructure/Services/UploadService.cs @@ -55,14 +55,9 @@ public async Task> UploadAsync(string folder, UploadRequest uploa return Result.Failure(result.HttpStatusCode.ToString()); } - catch (AmazonS3Exception s3Ex) - { - _logger.LogError(s3Ex, $"Error uploading file" ); - return Result.Failure(s3Ex.Message); - } catch (Exception ex) { - _logger.LogError(ex.Message, $"Error uploading file"); + _logger.LogError(ex, $"Error uploading file"); return Result.Failure(ex.Message); } } @@ -119,4 +114,4 @@ private static Dictionary CreateScopeInformation(string folder, }; return scopeInfo; } -} \ No newline at end of file +} From 50925c3268a23005dd374d90949db239f0bec80c Mon Sep 17 00:00:00 2001 From: Carl Sixsmith Date: Thu, 26 Sep 2024 12:56:09 +0100 Subject: [PATCH 04/27] CFODEV-761: Allow colons --- .../Common/Validators/RegularExpressionValidation.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Application/Common/Validators/RegularExpressionValidation.cs b/src/Application/Common/Validators/RegularExpressionValidation.cs index 6639c62e..717fef71 100644 --- a/src/Application/Common/Validators/RegularExpressionValidation.cs +++ b/src/Application/Common/Validators/RegularExpressionValidation.cs @@ -14,7 +14,7 @@ public static class ValidationConstants public const string DateMustBeInPast = "Date must be in the past."; public const string DateMustBeInFuture = "Date must be in the future."; - public const string Notes = @"^[A-Za-z0-9 ?.,!""'\/$£&€\r\n\-\(\)@’;%]*$"; + public const string Notes = @"^[A-Za-z0-9 ?.,!""'\/$£&€\r\n\-\(\)@’:;%]*$"; public const string NotesMessage = "{0} must contain only letters, numbers, spaces and common punctuation"; public const string GuidMessage = "{0} must contain a valid Guid"; From 517251c93c157da3e3c99076f45542230b79b072 Mon Sep 17 00:00:00 2001 From: Carl Sixsmith Date: Fri, 27 Sep 2024 12:43:51 +0100 Subject: [PATCH 05/27] Update the build.cake script -can now call migrate to generate the script changes that need applying. --- build.cake | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/build.cake b/build.cake index e8094bde..87aa7a13 100644 --- a/build.cake +++ b/build.cake @@ -3,6 +3,7 @@ var target = Argument("target", "Test"); var configuration = Argument("configuration", "Release"); +var fromVersion = Argument("fromVersion", ""); Task("Clean") @@ -63,4 +64,19 @@ Task("Publish") }); }); +Task("Migrate") + .IsDependentOn("Test") + .Does(() =>{ + var migrationProject = "src/Migrators/Migrators.MSSQL/Migrators.MSSQL.csproj"; + var startupProject = "src/Server.UI/Server.UI.csproj"; + var context = "Cfo.Cats.Infrastructure.Persistence.ApplicationDbContext"; + + + var result = StartProcess("dotnet", $"ef migrations script {fromVersion} --no-build --configuration {configuration} --project {migrationProject} --startup-project {startupProject} --context {context} --idempotent -o ./publish/MigrationScript.sql"); + if(result != 0) + { + Error("Failed to generate migration script"); + } + }); + RunTarget(target); From d6180c48c3d4322eb8788dedbd52645be8c1dcd6 Mon Sep 17 00:00:00 2001 From: Carl Sixsmith Date: Fri, 27 Sep 2024 16:42:21 +0100 Subject: [PATCH 06/27] Remove file from solution folder --- cats.sln | 1 - 1 file changed, 1 deletion(-) diff --git a/cats.sln b/cats.sln index 195b094b..0315327a 100644 --- a/cats.sln +++ b/cats.sln @@ -24,7 +24,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_SolutionItems", "_Solution docker-compose.yml = docker-compose.yml .config\dotnet-tools.json = .config\dotnet-tools.json LICENSE = LICENSE - LocalPublish.ps1 = LocalPublish.ps1 ModifyDatabase.ps1 = ModifyDatabase.ps1 NuGet.config = NuGet.config README.md = README.md From 63f1a5c1efb9dd8f482d8b837399c9f0abfd0ea4 Mon Sep 17 00:00:00 2001 From: VS Date: Mon, 30 Sep 2024 09:31:17 +0100 Subject: [PATCH 07/27] =?UTF-8?q?Risk=20due=20date=20is=20now=20reset=20to?= =?UTF-8?q?=2070=20days=20when=20user=20reviews=20the=20Risk=20with=20opti?= =?UTF-8?q?ons=20=E2=80=98No=20risk=20information=20available=E2=80=99=20o?= =?UTF-8?q?r=20=E2=80=98No=20change=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EventHandlers/RiskInformationReviewed.cs | 20 +++++++++++++++++++ src/Domain/Entities/Participants/Risk.cs | 5 ++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 src/Application/Features/Participants/EventHandlers/RiskInformationReviewed.cs diff --git a/src/Application/Features/Participants/EventHandlers/RiskInformationReviewed.cs b/src/Application/Features/Participants/EventHandlers/RiskInformationReviewed.cs new file mode 100644 index 00000000..c7116431 --- /dev/null +++ b/src/Application/Features/Participants/EventHandlers/RiskInformationReviewed.cs @@ -0,0 +1,20 @@ +using Cfo.Cats.Domain.Events; + +namespace Cfo.Cats.Application.Features.Participants.EventHandlers; + +public class RiskInformationReviewed(IUnitOfWork unitOfWork) : INotificationHandler +{ + public async Task Handle(RiskInformationReviewedDomainEvent notification, CancellationToken cancellationToken) + { + var participant = await unitOfWork.DbContext.Participants + .Where(p => p.Id == notification.Item.ParticipantId) + .FirstOrDefaultAsync(cancellationToken); + + if (participant is not null) + { + participant.SetRiskDue(DateTime.UtcNow.AddDays(70)); + unitOfWork.DbContext.Participants.Update(participant); + } + + } +} diff --git a/src/Domain/Entities/Participants/Risk.cs b/src/Domain/Entities/Participants/Risk.cs index 6fa72e4e..79517e5f 100644 --- a/src/Domain/Entities/Participants/Risk.cs +++ b/src/Domain/Entities/Participants/Risk.cs @@ -41,7 +41,10 @@ public static Risk Review(Risk from, RiskReviewReason reason, string? justificat from.Completed = null; from.CompletedBy = null; from.RegistrationDetailsJson = null; - from.AddDomainEvent(new RiskInformationReviewedDomainEvent(from)); + if (reason == RiskReviewReason.NoChange || reason ==RiskReviewReason.NoRiskInformationAvailable) + { + from.AddDomainEvent(new RiskInformationReviewedDomainEvent(from)); + } return from; } From 2e8f8f576d12f98ff4b16447ed081a35684a7212 Mon Sep 17 00:00:00 2001 From: Carl Sixsmith Date: Mon, 30 Sep 2024 10:59:25 +0100 Subject: [PATCH 08/27] CFODEV-752: This line is not required. --- .../Participants/EventHandlers/RiskInformationReviewed.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Application/Features/Participants/EventHandlers/RiskInformationReviewed.cs b/src/Application/Features/Participants/EventHandlers/RiskInformationReviewed.cs index c7116431..c0ac0408 100644 --- a/src/Application/Features/Participants/EventHandlers/RiskInformationReviewed.cs +++ b/src/Application/Features/Participants/EventHandlers/RiskInformationReviewed.cs @@ -13,7 +13,6 @@ public async Task Handle(RiskInformationReviewedDomainEvent notification, Cancel if (participant is not null) { participant.SetRiskDue(DateTime.UtcNow.AddDays(70)); - unitOfWork.DbContext.Participants.Update(participant); } } From 7716db2025210ccd19b3d81f7217b713dff8f407 Mon Sep 17 00:00:00 2001 From: VS Date: Wed, 18 Sep 2024 11:08:49 +0100 Subject: [PATCH 09/27] Added warning message on the participant screen that right to work required when participant->ConsentStatus is Granted --- .../Commands/CreateParticipant.cs | 3 +- .../Participants/DTOs/ParticipantDto.cs | 4 +- .../DTOs/ParticipantSummaryDto.cs | 14 +- .../Queries/GetParticipantSummary.cs | 6 + .../Entities/Participants/Participant.cs | 10 +- ...601_Participant_AddNationality.Designer.cs | 2725 +++++++++++++++++ ...240917060601_Participant_AddNationality.cs | 30 + .../ApplicationDbContextModelSnapshot.cs | 3 + .../Pages/Participants/Participant.razor | 43 + 9 files changed, 2830 insertions(+), 8 deletions(-) create mode 100644 src/Migrators/Migrators.MSSQL/Migrations/20240917060601_Participant_AddNationality.Designer.cs create mode 100644 src/Migrators/Migrators.MSSQL/Migrations/20240917060601_Participant_AddNationality.cs diff --git a/src/Application/Features/Participants/Commands/CreateParticipant.cs b/src/Application/Features/Participants/Commands/CreateParticipant.cs index e1cc614f..aafda4fa 100644 --- a/src/Application/Features/Participants/Commands/CreateParticipant.cs +++ b/src/Application/Features/Participants/Commands/CreateParticipant.cs @@ -61,7 +61,8 @@ public async Task> Handle(Command request, CancellationToken canc activeInFeed: candidate.IsActive, referralSource: request.ReferralSource!, referralComments: request.ReferralComments, - locationId: candidate.MappedLocationId); + locationId: candidate.MappedLocationId, + nationality: candidate.Nationality); if(candidate.Crn is not null) { diff --git a/src/Application/Features/Participants/DTOs/ParticipantDto.cs b/src/Application/Features/Participants/DTOs/ParticipantDto.cs index 73576901..5c5e284c 100644 --- a/src/Application/Features/Participants/DTOs/ParticipantDto.cs +++ b/src/Application/Features/Participants/DTOs/ParticipantDto.cs @@ -14,6 +14,7 @@ public class ParticipantDto public DateOnly? DateOfBirth { get; set; } public DateTime? RiskDue { get; set; } public int? RiskDueInDays { get; set; } + public string? Nationality { get; set; } [Description("Enrolment Status")] public EnrolmentStatus? EnrolmentStatus { get; set; } @@ -63,7 +64,8 @@ public Mapping() #nullable disable .ForMember(target => target.SupportWorker, options => options.MapFrom(source => source.Owner.DisplayName)) .ForMember(dest => dest.RiskDue, opt => opt.MapFrom(src => src.RiskDue)) - .ForMember(dest => dest.RiskDueInDays, opt => opt.MapFrom(src => src.RiskDueInDays())); + .ForMember(dest => dest.RiskDueInDays, opt => opt.MapFrom(src => src.RiskDueInDays())) + .ForMember(dest => dest.Nationality, opt => opt.MapFrom(src => src.Nationality)); } } } diff --git a/src/Application/Features/Participants/DTOs/ParticipantSummaryDto.cs b/src/Application/Features/Participants/DTOs/ParticipantSummaryDto.cs index 3084aea3..d0df00be 100644 --- a/src/Application/Features/Participants/DTOs/ParticipantSummaryDto.cs +++ b/src/Application/Features/Participants/DTOs/ParticipantSummaryDto.cs @@ -31,11 +31,18 @@ public class ParticipantSummaryDto public required DateOnly DateOfBirth { get; set; } public DateTime? RiskDue { get; set; } public int? RiskDueInDays { get; set; } + public string? Nationality { get; set; } /// /// The current enrolment status of the participant /// public EnrolmentStatus EnrolmentStatus { get; set; } = EnrolmentStatus.IdentifiedStatus; - + + /// + /// The current enrolment status of the participant + /// + public ConsentStatus ConsentStatus { get; set; } = ConsentStatus.PendingStatus; + + /// /// The person who "owns" this participant's case. Usually the support worker. /// @@ -49,6 +56,8 @@ public class ParticipantSummaryDto public PathwayPlanSummaryDto? PathwayPlan { get; set; } + public bool HasActiveRightToWork { get; set; } + private class Mapping : Profile { public Mapping() @@ -62,7 +71,8 @@ public Mapping() .ForMember(target => target.OwnerName, options => options.MapFrom(source => source.Owner!.DisplayName)) .ForMember(target => target.ParticipantName, options => options.MapFrom(source => source.FirstName + ' ' + source.LastName)) .ForMember(dest => dest.RiskDue, opt => opt.MapFrom(src => src.RiskDue)) - .ForMember(dest => dest.RiskDueInDays, opt => opt.MapFrom(src => src.RiskDueInDays())); + .ForMember(dest => dest.RiskDueInDays, opt => opt.MapFrom(src => src.RiskDueInDays())) + .ForMember(dest => dest.Nationality, opt => opt.MapFrom(src => src.Nationality)); CreateMap() .ForMember(target => target.AssessmentId, options => options.MapFrom(source => source.Id)) diff --git a/src/Application/Features/Participants/Queries/GetParticipantSummary.cs b/src/Application/Features/Participants/Queries/GetParticipantSummary.cs index 5ad3e7f3..288f2889 100644 --- a/src/Application/Features/Participants/Queries/GetParticipantSummary.cs +++ b/src/Application/Features/Participants/Queries/GetParticipantSummary.cs @@ -59,6 +59,12 @@ public async Task> Handle(Query request, Cancellat summary.BioSummary = mapper.Map(bio); + summary.HasActiveRightToWork = await unitOfWork.DbContext.Participants + .Where(x => x.Id == request.ParticipantId) + .SelectMany(p => p.RightToWorks) + .AnyAsync(x => DateOnly.FromDateTime(x.Lifetime.EndDate) >= DateOnly.FromDateTime(DateTime.UtcNow), cancellationToken); + + return Result.Success(summary); } } diff --git a/src/Domain/Entities/Participants/Participant.cs b/src/Domain/Entities/Participants/Participant.cs index 065b80c9..1d14b918 100644 --- a/src/Domain/Entities/Participants/Participant.cs +++ b/src/Domain/Entities/Participants/Participant.cs @@ -34,7 +34,8 @@ public static Participant CreateFrom( string? registrationDetailsJson, string referralSource, string? referralComments, - int locationId) + int locationId, + string? nationality) { Participant p = new() { @@ -50,8 +51,9 @@ public static Participant CreateFrom( RegistrationDetailsJson = registrationDetailsJson, ReferralSource = referralSource, ReferralComments = referralComments, - _currentLocationId = locationId - }; + _currentLocationId = locationId, + Nationality = nationality +}; p.AddDomainEvent(new ParticipantCreatedDomainEvent(p)); return p; @@ -64,7 +66,7 @@ public static Participant CreateFrom( public DateOnly DateOfBirth { get; private set; } public DateTime? RiskDue { get; private set; } public int? RiskDueInDays() => (RiskDue.HasValue ? (RiskDue!.Value.Date - DateTime.UtcNow.Date).Days:null); - + public string? Nationality { get; set; } /// /// Whether the participant is active in the DMS feed. /// diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20240917060601_Participant_AddNationality.Designer.cs b/src/Migrators/Migrators.MSSQL/Migrations/20240917060601_Participant_AddNationality.Designer.cs new file mode 100644 index 00000000..50af95c1 --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20240917060601_Participant_AddNationality.Designer.cs @@ -0,0 +1,2725 @@ +// +using System; +using Cfo.Cats.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Cfo.Cats.Migrators.MSSQL.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20240917060601_Participant_AddNationality")] + partial class Participant_AddNationality + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Contract", b => + { + b.Property("Id") + .HasMaxLength(12) + .HasColumnType("nvarchar(12)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LotNumber") + .HasColumnType("int"); + + b.Property("_tenantId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("LotNumber") + .IsUnique(); + + b.HasIndex("_tenantId"); + + b.ToTable("Contract", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("_contractId") + .HasMaxLength(12) + .HasColumnType("nvarchar(12)") + .HasColumnName("ContractId"); + + b.Property("_genderProvisionId") + .HasColumnType("int") + .HasColumnName("GenderProvisionId"); + + b.Property("_locationTypeId") + .HasColumnType("int") + .HasColumnName("LocationTypeId"); + + b.Property("_parentLocationId") + .HasColumnType("int") + .HasColumnName("ParentLocationId"); + + b.HasKey("Id"); + + b.HasIndex("_contractId"); + + b.HasIndex("_parentLocationId"); + + b.ToTable("Location", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.LocationMapping", b => + { + b.Property("Code") + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("CodeType") + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("DeliveryRegion") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("_locationId") + .HasColumnType("int") + .HasColumnName("LocationId"); + + b.HasKey("Code", "CodeType"); + + b.HasIndex("_locationId"); + + b.ToTable("LocationMapping", "Dms"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Tenant", b => + { + b.Property("Id") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Tenant", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Assessments.ParticipantAssessment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AssessmentJson") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Completed") + .HasColumnType("datetime2"); + + b.Property("CompletedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("Assessment", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.AuditTrail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AffectedColumns") + .HasColumnType("nvarchar(max)"); + + b.Property("AuditType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateTime") + .HasColumnType("datetime2"); + + b.Property("NewValues") + .HasColumnType("nvarchar(max)"); + + b.Property("OldValues") + .HasColumnType("nvarchar(max)"); + + b.Property("PrimaryKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TableName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AuditTrail", "Audit"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Bios.ParticipantBio", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("BioJson") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Completed") + .HasColumnType("datetime2"); + + b.Property("CompletedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("Bio", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Documents.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("DocumentType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("IsPublic") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("OwnerId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("TenantId") + .HasColumnType("nvarchar(50)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("URL") + .HasColumnType("nvarchar(max)"); + + b.Property("Version") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("LastModifiedBy"); + + b.HasIndex("TenantId"); + + b.ToTable("Document", "Document"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.IdentityAuditTrail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ActionType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("DateTime") + .HasColumnType("datetime2"); + + b.Property("IpAddress") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UserName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("UserName", "DateTime") + .HasDatabaseName("idx_IdentityAudit_UserName_DateTime"); + + b.ToTable("IdentityAuditTrail", "Audit"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.KeyValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Text") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("KeyValue", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentEscalationQueueEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("IsAccepted") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("EscalationQueue", "Enrolment"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentPqaQueueEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("IsAccepted") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("PqaQueue", "Enrolment"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa1QueueEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("IsAccepted") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("Qa1Queue", "Enrolment"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa2QueueEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("IsAccepted") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("Qa2Queue", "Enrolment"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Participant", b => + { + b.Property("Id") + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("ActiveInFeed") + .HasColumnType("bit"); + + b.Property("AssessmentJustification") + .HasColumnType("nvarchar(max)"); + + b.Property("ConsentStatus") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("DateOfBirth") + .HasColumnType("date"); + + b.Property("EditorId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("EnrolmentLocationJustification") + .HasColumnType("nvarchar(max)"); + + b.Property("EnrolmentStatus") + .HasColumnType("int"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Gender") + .HasMaxLength(6) + .HasColumnType("nvarchar(6)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MiddleName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Nationality") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ReferralComments") + .HasColumnType("nvarchar(max)"); + + b.Property("ReferralSource") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("RegistrationDetailsJson") + .HasColumnType("nvarchar(max)"); + + b.Property("RiskDue") + .HasColumnType("datetime2"); + + b.Property("_currentLocationId") + .HasColumnType("int") + .HasColumnName("CurrentLocationId"); + + b.Property("_enrolmentLocationId") + .HasColumnType("int") + .HasColumnName("EnrolmentLocationId"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("_currentLocationId"); + + b.HasIndex("_enrolmentLocationId"); + + b.ToTable("Participant", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.ParticipantEnrolmentHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("EnrolmentStatus") + .HasColumnType("int"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("EnrolmentHistory", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.PathwayPlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("PathwayPlan", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Risk", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityRecommendations") + .HasColumnType("nvarchar(max)"); + + b.Property("ActivityRecommendationsReceived") + .HasColumnType("datetime2"); + + b.Property("ActivityRestrictions") + .HasColumnType("nvarchar(max)"); + + b.Property("ActivityRestrictionsReceived") + .HasColumnType("datetime2"); + + b.Property("AdditionalInformation") + .HasColumnType("nvarchar(max)"); + + b.Property("Completed") + .HasColumnType("datetime2"); + + b.Property("CompletedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("IsRelevantToCommunity") + .HasColumnType("bit"); + + b.Property("IsRelevantToCustody") + .HasColumnType("bit"); + + b.Property("IsSubjectToSHPO") + .HasColumnType("int"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LicenseConditions") + .HasColumnType("nvarchar(max)"); + + b.Property("LicenseEnd") + .HasColumnType("datetime2"); + + b.Property("NSDCase") + .HasColumnType("int"); + + b.Property("PSFRestrictions") + .HasColumnType("nvarchar(max)"); + + b.Property("PSFRestrictionsReceived") + .HasColumnType("datetime2"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.Property("ReferredOn") + .HasColumnType("datetime2"); + + b.Property("ReferrerEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("ReferrerName") + .HasColumnType("nvarchar(max)"); + + b.Property("RegistrationDetailsJson") + .HasColumnType("nvarchar(max)"); + + b.Property("ReviewJustification") + .HasColumnType("nvarchar(max)"); + + b.Property("ReviewReason") + .HasColumnType("int"); + + b.Property("RiskToChildrenInCommunity") + .HasColumnType("int"); + + b.Property("RiskToChildrenInCustody") + .HasColumnType("int"); + + b.Property("RiskToKnownAdultInCommunity") + .HasColumnType("int"); + + b.Property("RiskToKnownAdultInCustody") + .HasColumnType("int"); + + b.Property("RiskToOtherPrisonersInCustody") + .HasColumnType("int"); + + b.Property("RiskToPublicInCommunity") + .HasColumnType("int"); + + b.Property("RiskToPublicInCustody") + .HasColumnType("int"); + + b.Property("RiskToSelfInCommunity") + .HasColumnType("int"); + + b.Property("RiskToSelfInCustody") + .HasColumnType("int"); + + b.Property("RiskToStaffInCommunity") + .HasColumnType("int"); + + b.Property("RiskToStaffInCustody") + .HasColumnType("int"); + + b.Property("SpecificRisk") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("Risk", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Timeline", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(36)"); + + b.Property("EventType") + .HasColumnType("int"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Line1") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Line2") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Line3") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ParticipantId"); + + b.ToTable("Timeline", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRole", b => + { + b.Property("Id") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("NormalizedName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RoleRank") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("Role", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Group") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RoleId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("RoleClaim", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUser", b => + { + b.Property("Id") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsLive") + .HasColumnType("bit"); + + b.Property("LastLogin") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("MemorableDate") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MemorablePlace") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("ProfilePictureDataUrl") + .HasColumnType("text"); + + b.Property("ProviderId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RefreshToken") + .HasColumnType("nvarchar(max)"); + + b.Property("RefreshTokenExpiryTime") + .HasColumnType("datetime2"); + + b.Property("RequiresPasswordReset") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("SuperiorId") + .HasColumnType("nvarchar(36)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TenantName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.HasIndex("SuperiorId"); + + b.HasIndex("TenantId"); + + b.ToTable("User", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserClaim", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserRole", b => + { + b.Property("UserId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("RoleId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("UserRole", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserToken", b => + { + b.Property("UserId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("UserToken", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.PasswordHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.ToTable("PasswordHistory", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.UserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("UserLogin", "Identity"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("FriendlyName") + .HasColumnType("nvarchar(max)"); + + b.Property("Xml") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("DataProtectionKeys"); + }); + + modelBuilder.Entity("TenantLocation", b => + { + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("nvarchar(50)"); + + b.HasKey("LocationId", "TenantId"); + + b.HasIndex("TenantId"); + + b.ToTable("TenantLocation", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Contract", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("_tenantId"); + + b.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b1 => + { + b1.Property("ContractId") + .HasColumnType("nvarchar(12)"); + + b1.Property("EndDate") + .HasColumnType("datetime2") + .HasColumnName("LifetimeEnd"); + + b1.Property("StartDate") + .HasColumnType("datetime2") + .HasColumnName("LifetimeStart"); + + b1.HasKey("ContractId"); + + b1.ToTable("Contract", "Configuration"); + + b1.WithOwner() + .HasForeignKey("ContractId"); + }); + + b.Navigation("Lifetime") + .IsRequired(); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Location", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Contract", "Contract") + .WithMany("Locations") + .HasForeignKey("_contractId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "ParentLocation") + .WithMany("ChildLocations") + .HasForeignKey("_parentLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b1 => + { + b1.Property("LocationId") + .HasColumnType("int"); + + b1.Property("EndDate") + .HasColumnType("datetime2") + .HasColumnName("LifetimeEnd"); + + b1.Property("StartDate") + .HasColumnType("datetime2") + .HasColumnName("LifetimeStart"); + + b1.HasKey("LocationId"); + + b1.ToTable("Location", "Configuration"); + + b1.WithOwner() + .HasForeignKey("LocationId"); + }); + + b.Navigation("Contract"); + + b.Navigation("Lifetime") + .IsRequired(); + + b.Navigation("ParentLocation"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.LocationMapping", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "Location") + .WithMany("LocationMappings") + .HasForeignKey("_locationId"); + + b.Navigation("Location"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Tenant", b => + { + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.TenantDomain", "Domains", b1 => + { + b1.Property("TenantId") + .HasColumnType("nvarchar(50)"); + + b1.Property("Domain") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.HasKey("TenantId", "Domain"); + + b1.ToTable("TenantDomain", "Configuration"); + + b1.WithOwner() + .HasForeignKey("TenantId"); + }); + + b.Navigation("Domains"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Assessments.ParticipantAssessment", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", null) + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.PathwayScore", "Scores", b1 => + { + b1.Property("AssessmentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Pathway") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b1.Property("Score") + .HasColumnType("float"); + + b1.HasKey("AssessmentId", "Pathway"); + + b1.ToTable("AssessmentPathwayScore", "Participant"); + + b1.WithOwner() + .HasForeignKey("AssessmentId"); + }); + + b.Navigation("Editor"); + + b.Navigation("Owner"); + + b.Navigation("Scores"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.AuditTrail", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Bios.ParticipantBio", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Documents.Document", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("LastModifiedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Editor"); + + b.Navigation("Owner"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentEscalationQueueEntry", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("EnrolmentEscalationQueueEntryId") + .HasColumnType("uniqueidentifier"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("EnrolmentEscalationQueueEntryId"); + + b1.HasIndex("LastModifiedBy"); + + b1.ToTable("EscalationNote", "Enrolment"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.WithOwner() + .HasForeignKey("EnrolmentEscalationQueueEntryId"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Editor"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("Participant"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentPqaQueueEntry", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("EnrolmentPqaQueueEntryId") + .HasColumnType("uniqueidentifier"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("EnrolmentPqaQueueEntryId"); + + b1.HasIndex("LastModifiedBy"); + + b1.ToTable("PqaQueueNote", "Enrolment"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.WithOwner() + .HasForeignKey("EnrolmentPqaQueueEntryId"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Editor"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("Participant"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa1QueueEntry", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("EnrolmentQa1QueueEntryId") + .HasColumnType("uniqueidentifier"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("EnrolmentQa1QueueEntryId"); + + b1.HasIndex("LastModifiedBy"); + + b1.ToTable("Qa1QueueNote", "Enrolment"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.WithOwner() + .HasForeignKey("EnrolmentQa1QueueEntryId"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Editor"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("Participant"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa2QueueEntry", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("EnrolmentQa2QueueEntryId") + .HasColumnType("uniqueidentifier"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("EnrolmentQa2QueueEntryId"); + + b1.HasIndex("LastModifiedBy"); + + b1.ToTable("Qa2QueueNote", "Enrolment"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.WithOwner() + .HasForeignKey("EnrolmentQa2QueueEntryId"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Editor"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("Participant"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Participant", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "CurrentLocation") + .WithMany() + .HasForeignKey("_currentLocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_Participant_Location"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "EnrolmentLocation") + .WithMany() + .HasForeignKey("_enrolmentLocationId") + .HasConstraintName("FK_Participant_EnrolmentLocation"); + + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.Consent", "Consents", b1 => + { + b1.Property("ParticipantId") + .HasColumnType("nvarchar(9)"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("_documentId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DocumentId"); + + b1.HasKey("ParticipantId", "Id"); + + b1.HasIndex("_documentId"); + + b1.ToTable("Consent", "Participant"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + + b1.HasOne("Cfo.Cats.Domain.Entities.Documents.Document", "Document") + .WithMany() + .HasForeignKey("_documentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b2 => + { + b2.Property("ConsentParticipantId") + .HasColumnType("nvarchar(9)"); + + b2.Property("ConsentId") + .HasColumnType("int"); + + b2.Property("EndDate") + .HasColumnType("datetime2") + .HasColumnName("ValidTo"); + + b2.Property("StartDate") + .HasColumnType("datetime2") + .HasColumnName("ValidFrom"); + + b2.HasKey("ConsentParticipantId", "ConsentId"); + + b2.ToTable("Consent", "Participant"); + + b2.WithOwner() + .HasForeignKey("ConsentParticipantId", "ConsentId"); + }); + + b1.Navigation("Document"); + + b1.Navigation("Lifetime") + .IsRequired(); + }); + + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.ExternalIdentifier", "ExternalIdentifiers", b1 => + { + b1.Property("Value") + .HasMaxLength(16) + .HasColumnType("nvarchar(16)"); + + b1.Property("Type") + .HasColumnType("int"); + + b1.Property("ParticipantId") + .HasColumnType("nvarchar(9)"); + + b1.HasKey("Value", "Type", "ParticipantId"); + + b1.HasIndex("ParticipantId"); + + b1.ToTable("ExternalIdentifier", "Participant"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + }); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b1.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("LastModifiedBy"); + + b1.HasIndex("ParticipantId"); + + b1.ToTable("Note", "Participant"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.RightToWork", "RightToWorks", b1 => + { + b1.Property("ParticipantId") + .HasColumnType("nvarchar(9)"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("_documentId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DocumentId"); + + b1.HasKey("ParticipantId", "Id"); + + b1.HasIndex("_documentId"); + + b1.ToTable("RightToWork", "Participant"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + + b1.HasOne("Cfo.Cats.Domain.Entities.Documents.Document", "Document") + .WithMany() + .HasForeignKey("_documentId"); + + b1.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b2 => + { + b2.Property("RightToWorkParticipantId") + .HasColumnType("nvarchar(9)"); + + b2.Property("RightToWorkId") + .HasColumnType("int"); + + b2.Property("EndDate") + .HasColumnType("datetime2") + .HasColumnName("ValidTo"); + + b2.Property("StartDate") + .HasColumnType("datetime2") + .HasColumnName("ValidFrom"); + + b2.HasKey("RightToWorkParticipantId", "RightToWorkId"); + + b2.ToTable("RightToWork", "Participant"); + + b2.WithOwner() + .HasForeignKey("RightToWorkParticipantId", "RightToWorkId"); + }); + + b1.Navigation("Document"); + + b1.Navigation("Lifetime") + .IsRequired(); + }); + + b.OwnsOne("Cfo.Cats.Domain.Entities.Participants.Supervisor", "Supervisor", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b1.Property("Address") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b1.Property("EmailAddress") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b1.Property("MobileNumber") + .HasMaxLength(16) + .HasColumnType("nvarchar(16)"); + + b1.Property("Name") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b1.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b1.Property("TelephoneNumber") + .HasMaxLength(16) + .HasColumnType("nvarchar(16)"); + + b1.HasKey("Id"); + + b1.HasIndex("ParticipantId") + .IsUnique(); + + b1.ToTable("Supervisor", "Participant"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + }); + + b.Navigation("Consents"); + + b.Navigation("CurrentLocation"); + + b.Navigation("Editor"); + + b.Navigation("EnrolmentLocation"); + + b.Navigation("ExternalIdentifiers"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("RightToWorks"); + + b.Navigation("Supervisor"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.PathwayPlan", b => + { + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.Objective", "Objectives", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b1.Property("Completed") + .HasColumnType("datetime2"); + + b1.Property("CompletedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("CompletedStatus") + .HasColumnType("int"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("Index") + .HasColumnType("int"); + + b1.Property("Justification") + .HasColumnType("nvarchar(max)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("PathwayPlanId") + .HasColumnType("uniqueidentifier"); + + b1.HasKey("Id"); + + b1.HasIndex("CompletedBy"); + + b1.HasIndex("PathwayPlanId"); + + b1.ToTable("Objective", "Participant"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CompletedByUser") + .WithMany() + .HasForeignKey("CompletedBy"); + + b1.WithOwner() + .HasForeignKey("PathwayPlanId"); + + b1.OwnsMany("Cfo.Cats.Domain.Entities.Participants.ObjectiveTask", "Tasks", b2 => + { + b2.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b2.Property("Completed") + .HasColumnType("datetime2"); + + b2.Property("CompletedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b2.Property("CompletedStatus") + .HasColumnType("int"); + + b2.Property("Created") + .HasColumnType("datetime2"); + + b2.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b2.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b2.Property("Due") + .HasColumnType("datetime2"); + + b2.Property("Index") + .HasColumnType("int"); + + b2.Property("Justification") + .HasColumnType("nvarchar(max)"); + + b2.Property("LastModified") + .HasColumnType("datetime2"); + + b2.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b2.Property("ObjectiveId") + .HasColumnType("uniqueidentifier"); + + b2.HasKey("Id"); + + b2.HasIndex("CompletedBy"); + + b2.HasIndex("ObjectiveId"); + + b2.ToTable("ObjectiveTask", "Participant"); + + b2.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CompletedByUser") + .WithMany() + .HasForeignKey("CompletedBy"); + + b2.WithOwner() + .HasForeignKey("ObjectiveId"); + + b2.Navigation("CompletedByUser"); + }); + + b1.Navigation("CompletedByUser"); + + b1.Navigation("Tasks"); + }); + + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.PathwayPlanReviewHistory", "ReviewHistories", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("PathwayPlanId") + .HasColumnType("uniqueidentifier"); + + b1.HasKey("Id"); + + b1.HasIndex("PathwayPlanId"); + + b1.ToTable("PathwayPlanReviewHistory", "Participant"); + + b1.WithOwner() + .HasForeignKey("PathwayPlanId"); + }); + + b.Navigation("Objectives"); + + b.Navigation("ReviewHistories"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Risk", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Timeline", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByUser"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRoleClaim", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationRole", "Role") + .WithMany("RoleClaims") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUser", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Superior") + .WithMany() + .HasForeignKey("SuperiorId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("LastModifiedBy"); + + b1.HasIndex("UserId"); + + b1.ToTable("Note", "Identity"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.WithOwner() + .HasForeignKey("UserId"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Notes"); + + b.Navigation("Superior"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserClaim", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserRole", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationRole", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserToken", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") + .WithMany("Tokens") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.UserLogin", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") + .WithMany("Logins") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("TenantLocation", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", null) + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", null) + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Contract", b => + { + b.Navigation("Locations"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Location", b => + { + b.Navigation("ChildLocations"); + + b.Navigation("LocationMappings"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRole", b => + { + b.Navigation("RoleClaims"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUser", b => + { + b.Navigation("Logins"); + + b.Navigation("Tokens"); + + b.Navigation("UserClaims"); + + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20240917060601_Participant_AddNationality.cs b/src/Migrators/Migrators.MSSQL/Migrations/20240917060601_Participant_AddNationality.cs new file mode 100644 index 00000000..c9922372 --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20240917060601_Participant_AddNationality.cs @@ -0,0 +1,30 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Cfo.Cats.Migrators.MSSQL.Migrations +{ + /// + public partial class Participant_AddNationality : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Nationality", + schema: "Participant", + table: "Participant", + type: "nvarchar(max)", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Nationality", + schema: "Participant", + table: "Participant"); + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs b/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs index 4af3f559..3bc459fc 100644 --- a/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs @@ -895,6 +895,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasMaxLength(50) .HasColumnType("nvarchar(50)"); + b.Property("Nationality") + .HasColumnType("nvarchar(max)"); + b.Property("OwnerId") .HasMaxLength(36) .HasColumnType("nvarchar(36)"); diff --git a/src/Server.UI/Pages/Participants/Participant.razor b/src/Server.UI/Pages/Participants/Participant.razor index 9e94fdb5..266fe6f4 100644 --- a/src/Server.UI/Pages/Participants/Participant.razor +++ b/src/Server.UI/Pages/Participants/Participant.razor @@ -85,12 +85,31 @@ @_participant.EnrolmentLocation + @if (_participant.ConsentStatus == ConsentStatus.GrantedStatus) + { + + + + Nationality + + + + + + @_participant.Nationality + + + } @if(_participant.EnrolmentStatus != EnrolmentStatus.IdentifiedStatus) { + @if (_showRightToWorkAlert) + { + @_rightToWorkAlertMessage + } @@ -146,12 +165,36 @@ private string _riskInfo = String.Empty; private string _riskIcon = String.Empty; private Color _riskIconColor = Color.Transparent; + private bool _showRightToWorkAlert = false; + private string _rightToWorkAlertMessage = string.Empty; protected override async Task OnInitializedAsync() { await Refresh(); await base.OnInitializedAsync(); SetRiskDueWarning(); + ShowRTW(); + } + + void ShowRTW() + { + //Check if the participant->EnrilmentStatus == Approved + if (_participant!.ConsentStatus == ConsentStatus.GrantedStatus) + { + if (string.Equals(_participant!.Nationality!, "British", StringComparison.OrdinalIgnoreCase) + || string.Equals(_participant!.Nationality!, "Irish", StringComparison.OrdinalIgnoreCase)) + { + _showRightToWorkAlert = false; + } + else + { + if (_participant.HasActiveRightToWork == false) + { + _rightToWorkAlertMessage = "No active Right To Work documentation found for the participant, it is a requirement for non-British/Irish participants."; + _showRightToWorkAlert = true; + } + } + } } void SetRiskDueWarning() From e0cb4c770b6664618c74ffacda49f5138a0b99df Mon Sep 17 00:00:00 2001 From: VS Date: Mon, 30 Sep 2024 11:43:30 +0100 Subject: [PATCH 10/27] changed query as suggested in the code review --- .../Features/Participants/Queries/GetParticipantSummary.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Application/Features/Participants/Queries/GetParticipantSummary.cs b/src/Application/Features/Participants/Queries/GetParticipantSummary.cs index 288f2889..b3332c26 100644 --- a/src/Application/Features/Participants/Queries/GetParticipantSummary.cs +++ b/src/Application/Features/Participants/Queries/GetParticipantSummary.cs @@ -62,7 +62,7 @@ public async Task> Handle(Query request, Cancellat summary.HasActiveRightToWork = await unitOfWork.DbContext.Participants .Where(x => x.Id == request.ParticipantId) .SelectMany(p => p.RightToWorks) - .AnyAsync(x => DateOnly.FromDateTime(x.Lifetime.EndDate) >= DateOnly.FromDateTime(DateTime.UtcNow), cancellationToken); + .AnyAsync(x => x.Lifetime.EndDate >= DateTime.Now.Date, cancellationToken); return Result.Success(summary); From d8a5daa5238d9233b7e25e761f833b2d5d3acdbb Mon Sep 17 00:00:00 2001 From: VS Date: Wed, 2 Oct 2024 08:54:00 +0100 Subject: [PATCH 11/27] updated code as suggested, also added Nationalities Exempt for Right to work in appsettings so that varItion in nationality text can be handled without code change --- .../Common/Interfaces/IRightToWorkSettings.cs | 7 + .../DTOs/ParticipantSummaryDto.cs | 1 + .../Queries/GetParticipantSummary.cs | 6 +- .../Configurations/RightToWorkSettings.cs | 9 + src/Infrastructure/DependencyInjection.cs | 6 + .../ParticipantEntityTypeConfiguration.cs | 3 + ...cipant_UpdateNationalityLength.Designer.cs | 2980 +++++++++++++++++ ...532_Participant_UpdateNationalityLength.cs | 40 + .../ApplicationDbContextModelSnapshot.cs | 21 +- .../Pages/Participants/Participant.razor | 30 +- src/Server.UI/appsettings.json | 6 + 11 files changed, 3074 insertions(+), 35 deletions(-) create mode 100644 src/Application/Common/Interfaces/IRightToWorkSettings.cs create mode 100644 src/Infrastructure/Configurations/RightToWorkSettings.cs create mode 100644 src/Migrators/Migrators.MSSQL/Migrations/20240930142532_Participant_UpdateNationalityLength.Designer.cs create mode 100644 src/Migrators/Migrators.MSSQL/Migrations/20240930142532_Participant_UpdateNationalityLength.cs diff --git a/src/Application/Common/Interfaces/IRightToWorkSettings.cs b/src/Application/Common/Interfaces/IRightToWorkSettings.cs new file mode 100644 index 00000000..fb03fbc0 --- /dev/null +++ b/src/Application/Common/Interfaces/IRightToWorkSettings.cs @@ -0,0 +1,7 @@ +namespace Cfo.Cats.Application.Common.Interfaces; + +public interface IRightToWorkSettings +{ + IList NationalitiesExempted { get; set; } +} + diff --git a/src/Application/Features/Participants/DTOs/ParticipantSummaryDto.cs b/src/Application/Features/Participants/DTOs/ParticipantSummaryDto.cs index d0df00be..6e21b306 100644 --- a/src/Application/Features/Participants/DTOs/ParticipantSummaryDto.cs +++ b/src/Application/Features/Participants/DTOs/ParticipantSummaryDto.cs @@ -57,6 +57,7 @@ public class ParticipantSummaryDto public PathwayPlanSummaryDto? PathwayPlan { get; set; } public bool HasActiveRightToWork { get; set; } + public bool IsRightToWorkRequired{ get; set; } private class Mapping : Profile { diff --git a/src/Application/Features/Participants/Queries/GetParticipantSummary.cs b/src/Application/Features/Participants/Queries/GetParticipantSummary.cs index b3332c26..7b68db0a 100644 --- a/src/Application/Features/Participants/Queries/GetParticipantSummary.cs +++ b/src/Application/Features/Participants/Queries/GetParticipantSummary.cs @@ -18,10 +18,9 @@ public class Query : IAuditableRequest> public string Identifier() => ParticipantId; } - - public class Handler(IUnitOfWork unitOfWork, IMapper mapper) : IRequestHandler> + public class Handler(IUnitOfWork unitOfWork, IMapper mapper, IRightToWorkSettings rtwSettings) : IRequestHandler> { - + public async Task> Handle(Query request, CancellationToken cancellationToken) { var query = from c in unitOfWork.DbContext.Participants @@ -64,6 +63,7 @@ public async Task> Handle(Query request, Cancellat .SelectMany(p => p.RightToWorks) .AnyAsync(x => x.Lifetime.EndDate >= DateTime.Now.Date, cancellationToken); + summary.IsRightToWorkRequired = rtwSettings.NationalitiesExempted.Any(s => s.Equals(summary.Nationality!, StringComparison.OrdinalIgnoreCase)) == false; return Result.Success(summary); } diff --git a/src/Infrastructure/Configurations/RightToWorkSettings.cs b/src/Infrastructure/Configurations/RightToWorkSettings.cs new file mode 100644 index 00000000..2851ffd2 --- /dev/null +++ b/src/Infrastructure/Configurations/RightToWorkSettings.cs @@ -0,0 +1,9 @@ +using Cfo.Cats.Application.Common.Interfaces; +namespace Cfo.Cats.Infrastructure.Configurations; + +public class RightToWorkSettings : IRightToWorkSettings +{ + public const string Key = nameof(RightToWorkSettings); + public IList NationalitiesExempted { get; set; } = new List(); + +} \ No newline at end of file diff --git a/src/Infrastructure/DependencyInjection.cs b/src/Infrastructure/DependencyInjection.cs index ac66faf3..93ae2a85 100644 --- a/src/Infrastructure/DependencyInjection.cs +++ b/src/Infrastructure/DependencyInjection.cs @@ -3,6 +3,7 @@ using Cfo.Cats.Application.Common.Interfaces.Locations; using Cfo.Cats.Application.Common.Interfaces.MultiTenant; using Cfo.Cats.Application.Common.Interfaces.Serialization; +using Cfo.Cats.Application.Features.Participants.Queries; using Cfo.Cats.Application.SecurityConstants; using Cfo.Cats.Domain.Identity; using Cfo.Cats.Infrastructure.Configurations; @@ -64,6 +65,11 @@ IConfiguration configuration .Configure(configuration.GetSection(DatabaseSettings.Key)) .AddSingleton(s => s.GetRequiredService>().Value); + services.Configure(configuration.GetSection(RightToWorkSettings.Key)) + .AddSingleton(s => s.GetRequiredService>().Value) + .AddSingleton(s => + s.GetRequiredService() + ); return services; } diff --git a/src/Infrastructure/Persistence/Configurations/Participants/ParticipantEntityTypeConfiguration.cs b/src/Infrastructure/Persistence/Configurations/Participants/ParticipantEntityTypeConfiguration.cs index bdf00c63..ec5722f8 100644 --- a/src/Infrastructure/Persistence/Configurations/Participants/ParticipantEntityTypeConfiguration.cs +++ b/src/Infrastructure/Persistence/Configurations/Participants/ParticipantEntityTypeConfiguration.cs @@ -38,6 +38,9 @@ public void Configure(EntityTypeBuilder builder) builder.Property(p => p.Gender) .HasMaxLength(6); + builder.Property(p => p.Nationality) + .HasMaxLength(50); + builder.Property(p => p.ActiveInFeed) .IsRequired(); diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20240930142532_Participant_UpdateNationalityLength.Designer.cs b/src/Migrators/Migrators.MSSQL/Migrations/20240930142532_Participant_UpdateNationalityLength.Designer.cs new file mode 100644 index 00000000..d0fc02ab --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20240930142532_Participant_UpdateNationalityLength.Designer.cs @@ -0,0 +1,2980 @@ +// +using System; +using Cfo.Cats.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Cfo.Cats.Migrators.MSSQL.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20240930142532_Participant_UpdateNationalityLength")] + partial class Participant_UpdateNationalityLength + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Contract", b => + { + b.Property("Id") + .HasMaxLength(12) + .HasColumnType("nvarchar(12)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LotNumber") + .HasColumnType("int"); + + b.Property("_tenantId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("LotNumber") + .IsUnique(); + + b.HasIndex("_tenantId"); + + b.ToTable("Contract", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("_contractId") + .HasMaxLength(12) + .HasColumnType("nvarchar(12)") + .HasColumnName("ContractId"); + + b.Property("_genderProvisionId") + .HasColumnType("int") + .HasColumnName("GenderProvisionId"); + + b.Property("_locationTypeId") + .HasColumnType("int") + .HasColumnName("LocationTypeId"); + + b.Property("_parentLocationId") + .HasColumnType("int") + .HasColumnName("ParentLocationId"); + + b.HasKey("Id"); + + b.HasIndex("_contractId"); + + b.HasIndex("_parentLocationId"); + + b.ToTable("Location", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.LocationMapping", b => + { + b.Property("Code") + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("CodeType") + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("DeliveryRegion") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("_locationId") + .HasColumnType("int") + .HasColumnName("LocationId"); + + b.HasKey("Code", "CodeType"); + + b.HasIndex("_locationId"); + + b.ToTable("LocationMapping", "Dms"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Tenant", b => + { + b.Property("Id") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Tenant", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Assessments.ParticipantAssessment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AssessmentJson") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Completed") + .HasColumnType("datetime2"); + + b.Property("CompletedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("Assessment", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.AuditTrail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AffectedColumns") + .HasColumnType("nvarchar(max)"); + + b.Property("AuditType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateTime") + .HasColumnType("datetime2"); + + b.Property("NewValues") + .HasColumnType("nvarchar(max)"); + + b.Property("OldValues") + .HasColumnType("nvarchar(max)"); + + b.Property("PrimaryKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TableName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AuditTrail", "Audit"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Bios.ParticipantBio", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("BioJson") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Completed") + .HasColumnType("datetime2"); + + b.Property("CompletedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("Bio", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Documents.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("DocumentType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("IsPublic") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("OwnerId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("TenantId") + .HasColumnType("nvarchar(50)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("URL") + .HasColumnType("nvarchar(max)"); + + b.Property("Version") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("LastModifiedBy"); + + b.HasIndex("TenantId"); + + b.ToTable("Document", "Document"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.IdentityAuditTrail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ActionType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("DateTime") + .HasColumnType("datetime2"); + + b.Property("IpAddress") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UserName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("UserName", "DateTime") + .HasDatabaseName("idx_IdentityAudit_UserName_DateTime"); + + b.ToTable("IdentityAuditTrail", "Audit"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Inductions.HubInduction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("InductionDate") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("OwnerId") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("CreatedBy"); + + b.HasIndex("EditorId"); + + b.HasIndex("LocationId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId", "Created"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("ParticipantId", "Created")); + + b.ToTable("HubInduction", "Induction"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Inductions.WingInduction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("InductionDate") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("OwnerId") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("CreatedBy"); + + b.HasIndex("EditorId"); + + b.HasIndex("LocationId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId", "Created"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("ParticipantId", "Created")); + + b.ToTable("WingInduction", "Induction"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.KeyValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Text") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("KeyValue", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.ParticipantAccessAuditTrail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AccessDate") + .HasColumnType("datetime2"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("RequestType") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("AccessAuditTrail", "Audit"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentEscalationQueueEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("IsAccepted") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("EscalationQueue", "Enrolment"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentPqaQueueEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("IsAccepted") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("PqaQueue", "Enrolment"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa1QueueEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("IsAccepted") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("Qa1Queue", "Enrolment"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa2QueueEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("IsAccepted") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("Qa2Queue", "Enrolment"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Participant", b => + { + b.Property("Id") + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("ActiveInFeed") + .HasColumnType("bit"); + + b.Property("AssessmentJustification") + .HasColumnType("nvarchar(max)"); + + b.Property("ConsentStatus") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("DateOfBirth") + .HasColumnType("date"); + + b.Property("EditorId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("EnrolmentLocationJustification") + .HasColumnType("nvarchar(max)"); + + b.Property("EnrolmentStatus") + .HasColumnType("int"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Gender") + .HasMaxLength(6) + .HasColumnType("nvarchar(6)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MiddleName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Nationality") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("OwnerId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ReferralComments") + .HasColumnType("nvarchar(max)"); + + b.Property("ReferralSource") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("RegistrationDetailsJson") + .HasColumnType("nvarchar(max)"); + + b.Property("RiskDue") + .HasColumnType("datetime2"); + + b.Property("_currentLocationId") + .HasColumnType("int") + .HasColumnName("CurrentLocationId"); + + b.Property("_enrolmentLocationId") + .HasColumnType("int") + .HasColumnName("EnrolmentLocationId"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("_currentLocationId"); + + b.HasIndex("_enrolmentLocationId"); + + b.ToTable("Participant", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.ParticipantEnrolmentHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("EnrolmentStatus") + .HasColumnType("int"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("EnrolmentHistory", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.PathwayPlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("PathwayPlan", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Risk", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityRecommendations") + .HasColumnType("nvarchar(max)"); + + b.Property("ActivityRecommendationsReceived") + .HasColumnType("datetime2"); + + b.Property("ActivityRestrictions") + .HasColumnType("nvarchar(max)"); + + b.Property("ActivityRestrictionsReceived") + .HasColumnType("datetime2"); + + b.Property("AdditionalInformation") + .HasColumnType("nvarchar(max)"); + + b.Property("Completed") + .HasColumnType("datetime2"); + + b.Property("CompletedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("IsRelevantToCommunity") + .HasColumnType("bit"); + + b.Property("IsRelevantToCustody") + .HasColumnType("bit"); + + b.Property("IsSubjectToSHPO") + .HasColumnType("int"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LicenseConditions") + .HasColumnType("nvarchar(max)"); + + b.Property("LicenseEnd") + .HasColumnType("datetime2"); + + b.Property("NSDCase") + .HasColumnType("int"); + + b.Property("PSFRestrictions") + .HasColumnType("nvarchar(max)"); + + b.Property("PSFRestrictionsReceived") + .HasColumnType("datetime2"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.Property("ReferredOn") + .HasColumnType("datetime2"); + + b.Property("ReferrerEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("ReferrerName") + .HasColumnType("nvarchar(max)"); + + b.Property("RegistrationDetailsJson") + .HasColumnType("nvarchar(max)"); + + b.Property("ReviewJustification") + .HasColumnType("nvarchar(max)"); + + b.Property("ReviewReason") + .HasColumnType("int"); + + b.Property("RiskToChildrenInCommunity") + .HasColumnType("int"); + + b.Property("RiskToChildrenInCustody") + .HasColumnType("int"); + + b.Property("RiskToKnownAdultInCommunity") + .HasColumnType("int"); + + b.Property("RiskToKnownAdultInCustody") + .HasColumnType("int"); + + b.Property("RiskToOtherPrisonersInCustody") + .HasColumnType("int"); + + b.Property("RiskToPublicInCommunity") + .HasColumnType("int"); + + b.Property("RiskToPublicInCustody") + .HasColumnType("int"); + + b.Property("RiskToSelfInCommunity") + .HasColumnType("int"); + + b.Property("RiskToSelfInCustody") + .HasColumnType("int"); + + b.Property("RiskToStaffInCommunity") + .HasColumnType("int"); + + b.Property("RiskToStaffInCustody") + .HasColumnType("int"); + + b.Property("SpecificRisk") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("Risk", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Timeline", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(36)"); + + b.Property("EventType") + .HasColumnType("int"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Line1") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Line2") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Line3") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ParticipantId"); + + b.ToTable("Timeline", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRole", b => + { + b.Property("Id") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("NormalizedName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RoleRank") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("Role", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Group") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RoleId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("RoleClaim", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUser", b => + { + b.Property("Id") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsLive") + .HasColumnType("bit"); + + b.Property("LastLogin") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("MemorableDate") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MemorablePlace") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("ProfilePictureDataUrl") + .HasColumnType("text"); + + b.Property("ProviderId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RefreshToken") + .HasColumnType("nvarchar(max)"); + + b.Property("RefreshTokenExpiryTime") + .HasColumnType("datetime2"); + + b.Property("RequiresPasswordReset") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("SuperiorId") + .HasColumnType("nvarchar(36)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TenantName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.HasIndex("SuperiorId"); + + b.HasIndex("TenantId"); + + b.ToTable("User", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserClaim", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserRole", b => + { + b.Property("UserId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("RoleId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("UserRole", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserToken", b => + { + b.Property("UserId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("UserToken", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.PasswordHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.ToTable("PasswordHistory", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.UserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("UserLogin", "Identity"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("FriendlyName") + .HasColumnType("nvarchar(max)"); + + b.Property("Xml") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("DataProtectionKeys"); + }); + + modelBuilder.Entity("TenantLocation", b => + { + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("nvarchar(50)"); + + b.HasKey("LocationId", "TenantId"); + + b.HasIndex("TenantId"); + + b.ToTable("TenantLocation", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Contract", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("_tenantId"); + + b.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b1 => + { + b1.Property("ContractId") + .HasColumnType("nvarchar(12)"); + + b1.Property("EndDate") + .HasColumnType("datetime2") + .HasColumnName("LifetimeEnd"); + + b1.Property("StartDate") + .HasColumnType("datetime2") + .HasColumnName("LifetimeStart"); + + b1.HasKey("ContractId"); + + b1.ToTable("Contract", "Configuration"); + + b1.WithOwner() + .HasForeignKey("ContractId"); + }); + + b.Navigation("Lifetime") + .IsRequired(); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Location", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Contract", "Contract") + .WithMany("Locations") + .HasForeignKey("_contractId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "ParentLocation") + .WithMany("ChildLocations") + .HasForeignKey("_parentLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b1 => + { + b1.Property("LocationId") + .HasColumnType("int"); + + b1.Property("EndDate") + .HasColumnType("datetime2") + .HasColumnName("LifetimeEnd"); + + b1.Property("StartDate") + .HasColumnType("datetime2") + .HasColumnName("LifetimeStart"); + + b1.HasKey("LocationId"); + + b1.ToTable("Location", "Configuration"); + + b1.WithOwner() + .HasForeignKey("LocationId"); + }); + + b.Navigation("Contract"); + + b.Navigation("Lifetime") + .IsRequired(); + + b.Navigation("ParentLocation"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.LocationMapping", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "Location") + .WithMany("LocationMappings") + .HasForeignKey("_locationId"); + + b.Navigation("Location"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Tenant", b => + { + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.TenantDomain", "Domains", b1 => + { + b1.Property("TenantId") + .HasColumnType("nvarchar(50)"); + + b1.Property("Domain") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.HasKey("TenantId", "Domain"); + + b1.ToTable("TenantDomain", "Configuration"); + + b1.WithOwner() + .HasForeignKey("TenantId"); + }); + + b.Navigation("Domains"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Assessments.ParticipantAssessment", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", null) + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.PathwayScore", "Scores", b1 => + { + b1.Property("AssessmentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Pathway") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b1.Property("Score") + .HasColumnType("float"); + + b1.HasKey("AssessmentId", "Pathway"); + + b1.ToTable("AssessmentPathwayScore", "Participant"); + + b1.WithOwner() + .HasForeignKey("AssessmentId"); + }); + + b.Navigation("Editor"); + + b.Navigation("Owner"); + + b.Navigation("Scores"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.AuditTrail", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Bios.ParticipantBio", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Documents.Document", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("LastModifiedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Editor"); + + b.Navigation("Owner"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Inductions.HubInduction", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Editor"); + + b.Navigation("Location"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Inductions.WingInduction", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.Entities.Inductions.InductionPhase", "Phases", b1 => + { + b1.Property("WingInductionId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Number") + .HasColumnType("int"); + + b1.Property("CompletedDate") + .HasColumnType("datetime2"); + + b1.Property("StartDate") + .HasColumnType("datetime2"); + + b1.HasKey("WingInductionId", "Number"); + + b1.ToTable("WingInductionPhase", "Induction"); + + b1.WithOwner() + .HasForeignKey("WingInductionId"); + }); + + b.Navigation("Editor"); + + b.Navigation("Location"); + + b.Navigation("Owner"); + + b.Navigation("Phases"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.ParticipantAccessAuditTrail", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentEscalationQueueEntry", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("EnrolmentEscalationQueueEntryId") + .HasColumnType("uniqueidentifier"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("EnrolmentEscalationQueueEntryId"); + + b1.HasIndex("LastModifiedBy"); + + b1.ToTable("EscalationNote", "Enrolment"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.WithOwner() + .HasForeignKey("EnrolmentEscalationQueueEntryId"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Editor"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("Participant"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentPqaQueueEntry", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("EnrolmentPqaQueueEntryId") + .HasColumnType("uniqueidentifier"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("EnrolmentPqaQueueEntryId"); + + b1.HasIndex("LastModifiedBy"); + + b1.ToTable("PqaQueueNote", "Enrolment"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.WithOwner() + .HasForeignKey("EnrolmentPqaQueueEntryId"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Editor"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("Participant"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa1QueueEntry", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("EnrolmentQa1QueueEntryId") + .HasColumnType("uniqueidentifier"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("EnrolmentQa1QueueEntryId"); + + b1.HasIndex("LastModifiedBy"); + + b1.ToTable("Qa1QueueNote", "Enrolment"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.WithOwner() + .HasForeignKey("EnrolmentQa1QueueEntryId"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Editor"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("Participant"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa2QueueEntry", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("EnrolmentQa2QueueEntryId") + .HasColumnType("uniqueidentifier"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("EnrolmentQa2QueueEntryId"); + + b1.HasIndex("LastModifiedBy"); + + b1.ToTable("Qa2QueueNote", "Enrolment"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.WithOwner() + .HasForeignKey("EnrolmentQa2QueueEntryId"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Editor"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("Participant"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Participant", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "CurrentLocation") + .WithMany() + .HasForeignKey("_currentLocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_Participant_Location"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "EnrolmentLocation") + .WithMany() + .HasForeignKey("_enrolmentLocationId") + .HasConstraintName("FK_Participant_EnrolmentLocation"); + + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.Consent", "Consents", b1 => + { + b1.Property("ParticipantId") + .HasColumnType("nvarchar(9)"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("_documentId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DocumentId"); + + b1.HasKey("ParticipantId", "Id"); + + b1.HasIndex("_documentId"); + + b1.ToTable("Consent", "Participant"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + + b1.HasOne("Cfo.Cats.Domain.Entities.Documents.Document", "Document") + .WithMany() + .HasForeignKey("_documentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b2 => + { + b2.Property("ConsentParticipantId") + .HasColumnType("nvarchar(9)"); + + b2.Property("ConsentId") + .HasColumnType("int"); + + b2.Property("EndDate") + .HasColumnType("datetime2") + .HasColumnName("ValidTo"); + + b2.Property("StartDate") + .HasColumnType("datetime2") + .HasColumnName("ValidFrom"); + + b2.HasKey("ConsentParticipantId", "ConsentId"); + + b2.ToTable("Consent", "Participant"); + + b2.WithOwner() + .HasForeignKey("ConsentParticipantId", "ConsentId"); + }); + + b1.Navigation("Document"); + + b1.Navigation("Lifetime") + .IsRequired(); + }); + + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.ExternalIdentifier", "ExternalIdentifiers", b1 => + { + b1.Property("Value") + .HasMaxLength(16) + .HasColumnType("nvarchar(16)"); + + b1.Property("Type") + .HasColumnType("int"); + + b1.Property("ParticipantId") + .HasColumnType("nvarchar(9)"); + + b1.HasKey("Value", "Type", "ParticipantId"); + + b1.HasIndex("ParticipantId"); + + b1.ToTable("ExternalIdentifier", "Participant"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + }); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b1.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("LastModifiedBy"); + + b1.HasIndex("ParticipantId"); + + b1.ToTable("Note", "Participant"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.RightToWork", "RightToWorks", b1 => + { + b1.Property("ParticipantId") + .HasColumnType("nvarchar(9)"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("_documentId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DocumentId"); + + b1.HasKey("ParticipantId", "Id"); + + b1.HasIndex("_documentId"); + + b1.ToTable("RightToWork", "Participant"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + + b1.HasOne("Cfo.Cats.Domain.Entities.Documents.Document", "Document") + .WithMany() + .HasForeignKey("_documentId"); + + b1.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b2 => + { + b2.Property("RightToWorkParticipantId") + .HasColumnType("nvarchar(9)"); + + b2.Property("RightToWorkId") + .HasColumnType("int"); + + b2.Property("EndDate") + .HasColumnType("datetime2") + .HasColumnName("ValidTo"); + + b2.Property("StartDate") + .HasColumnType("datetime2") + .HasColumnName("ValidFrom"); + + b2.HasKey("RightToWorkParticipantId", "RightToWorkId"); + + b2.ToTable("RightToWork", "Participant"); + + b2.WithOwner() + .HasForeignKey("RightToWorkParticipantId", "RightToWorkId"); + }); + + b1.Navigation("Document"); + + b1.Navigation("Lifetime") + .IsRequired(); + }); + + b.OwnsOne("Cfo.Cats.Domain.Entities.Participants.Supervisor", "Supervisor", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b1.Property("Address") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b1.Property("EmailAddress") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b1.Property("MobileNumber") + .HasMaxLength(16) + .HasColumnType("nvarchar(16)"); + + b1.Property("Name") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b1.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b1.Property("TelephoneNumber") + .HasMaxLength(16) + .HasColumnType("nvarchar(16)"); + + b1.HasKey("Id"); + + b1.HasIndex("ParticipantId") + .IsUnique(); + + b1.ToTable("Supervisor", "Participant"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + }); + + b.Navigation("Consents"); + + b.Navigation("CurrentLocation"); + + b.Navigation("Editor"); + + b.Navigation("EnrolmentLocation"); + + b.Navigation("ExternalIdentifiers"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("RightToWorks"); + + b.Navigation("Supervisor"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.PathwayPlan", b => + { + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.Objective", "Objectives", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b1.Property("Completed") + .HasColumnType("datetime2"); + + b1.Property("CompletedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("CompletedStatus") + .HasColumnType("int"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("Index") + .HasColumnType("int"); + + b1.Property("Justification") + .HasColumnType("nvarchar(max)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("PathwayPlanId") + .HasColumnType("uniqueidentifier"); + + b1.HasKey("Id"); + + b1.HasIndex("CompletedBy"); + + b1.HasIndex("PathwayPlanId"); + + b1.ToTable("Objective", "Participant"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CompletedByUser") + .WithMany() + .HasForeignKey("CompletedBy"); + + b1.WithOwner() + .HasForeignKey("PathwayPlanId"); + + b1.OwnsMany("Cfo.Cats.Domain.Entities.Participants.ObjectiveTask", "Tasks", b2 => + { + b2.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b2.Property("Completed") + .HasColumnType("datetime2"); + + b2.Property("CompletedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b2.Property("CompletedStatus") + .HasColumnType("int"); + + b2.Property("Created") + .HasColumnType("datetime2"); + + b2.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b2.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b2.Property("Due") + .HasColumnType("datetime2"); + + b2.Property("Index") + .HasColumnType("int"); + + b2.Property("Justification") + .HasColumnType("nvarchar(max)"); + + b2.Property("LastModified") + .HasColumnType("datetime2"); + + b2.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b2.Property("ObjectiveId") + .HasColumnType("uniqueidentifier"); + + b2.HasKey("Id"); + + b2.HasIndex("CompletedBy"); + + b2.HasIndex("ObjectiveId"); + + b2.ToTable("ObjectiveTask", "Participant"); + + b2.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CompletedByUser") + .WithMany() + .HasForeignKey("CompletedBy"); + + b2.WithOwner() + .HasForeignKey("ObjectiveId"); + + b2.Navigation("CompletedByUser"); + }); + + b1.Navigation("CompletedByUser"); + + b1.Navigation("Tasks"); + }); + + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.PathwayPlanReviewHistory", "ReviewHistories", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("PathwayPlanId") + .HasColumnType("uniqueidentifier"); + + b1.HasKey("Id"); + + b1.HasIndex("PathwayPlanId"); + + b1.ToTable("PathwayPlanReviewHistory", "Participant"); + + b1.WithOwner() + .HasForeignKey("PathwayPlanId"); + }); + + b.Navigation("Objectives"); + + b.Navigation("ReviewHistories"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Risk", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Timeline", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByUser"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRoleClaim", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationRole", "Role") + .WithMany("RoleClaims") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUser", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Superior") + .WithMany() + .HasForeignKey("SuperiorId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("LastModifiedBy"); + + b1.HasIndex("UserId"); + + b1.ToTable("Note", "Identity"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.WithOwner() + .HasForeignKey("UserId"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Notes"); + + b.Navigation("Superior"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserClaim", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserRole", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationRole", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserToken", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") + .WithMany("Tokens") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.UserLogin", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") + .WithMany("Logins") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("TenantLocation", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", null) + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", null) + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Contract", b => + { + b.Navigation("Locations"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Location", b => + { + b.Navigation("ChildLocations"); + + b.Navigation("LocationMappings"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRole", b => + { + b.Navigation("RoleClaims"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUser", b => + { + b.Navigation("Logins"); + + b.Navigation("Tokens"); + + b.Navigation("UserClaims"); + + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20240930142532_Participant_UpdateNationalityLength.cs b/src/Migrators/Migrators.MSSQL/Migrations/20240930142532_Participant_UpdateNationalityLength.cs new file mode 100644 index 00000000..179bc8f4 --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20240930142532_Participant_UpdateNationalityLength.cs @@ -0,0 +1,40 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Cfo.Cats.Migrators.MSSQL.Migrations +{ + /// + public partial class Participant_UpdateNationalityLength : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Nationality", + schema: "Participant", + table: "Participant", + type: "nvarchar(50)", + maxLength: 50, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Nationality", + schema: "Participant", + table: "Participant", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(50)", + oldMaxLength: 50, + oldNullable: true); + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs b/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs index 3bc459fc..5940e776 100644 --- a/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs @@ -896,7 +896,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("nvarchar(50)"); b.Property("Nationality") - .HasColumnType("nvarchar(max)"); + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); b.Property("OwnerId") .HasMaxLength(36) @@ -1762,15 +1763,6 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Tenant"); }); - modelBuilder.Entity("Cfo.Cats.Domain.Entities.ParticipantAccessAuditTrail", b => - { - b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) - .WithMany() - .HasForeignKey("ParticipantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Inductions.HubInduction", b => { b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", null) @@ -1869,6 +1861,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Phases"); }); + modelBuilder.Entity("Cfo.Cats.Domain.Entities.ParticipantAccessAuditTrail", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentEscalationQueueEntry", b => { b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") diff --git a/src/Server.UI/Pages/Participants/Participant.razor b/src/Server.UI/Pages/Participants/Participant.razor index 266fe6f4..c2f5dbf0 100644 --- a/src/Server.UI/Pages/Participants/Participant.razor +++ b/src/Server.UI/Pages/Participants/Participant.razor @@ -106,7 +106,7 @@ { - @if (_showRightToWorkAlert) + @if (_showRightToWorkWarning) { @_rightToWorkAlertMessage } @@ -165,36 +165,22 @@ private string _riskInfo = String.Empty; private string _riskIcon = String.Empty; private Color _riskIconColor = Color.Transparent; - private bool _showRightToWorkAlert = false; - private string _rightToWorkAlertMessage = string.Empty; + private bool _showRightToWorkWarning = false; + private string _rightToWorkAlertMessage = "No active Right To Work documentation found for the participant, it is a requirement for non-British/Irish participants."; protected override async Task OnInitializedAsync() { await Refresh(); await base.OnInitializedAsync(); SetRiskDueWarning(); - ShowRTW(); + ShowRightToWorkWarning(); } - void ShowRTW() + void ShowRightToWorkWarning() { - //Check if the participant->EnrilmentStatus == Approved - if (_participant!.ConsentStatus == ConsentStatus.GrantedStatus) - { - if (string.Equals(_participant!.Nationality!, "British", StringComparison.OrdinalIgnoreCase) - || string.Equals(_participant!.Nationality!, "Irish", StringComparison.OrdinalIgnoreCase)) - { - _showRightToWorkAlert = false; - } - else - { - if (_participant.HasActiveRightToWork == false) - { - _rightToWorkAlertMessage = "No active Right To Work documentation found for the participant, it is a requirement for non-British/Irish participants."; - _showRightToWorkAlert = true; - } - } - } + _showRightToWorkWarning = _participant!.IsRightToWorkRequired + && _participant!.ConsentStatus == ConsentStatus.GrantedStatus + && _participant.HasActiveRightToWork == false; } void SetRiskDueWarning() diff --git a/src/Server.UI/appsettings.json b/src/Server.UI/appsettings.json index fc16e0ab..44d9526a 100644 --- a/src/Server.UI/appsettings.json +++ b/src/Server.UI/appsettings.json @@ -157,5 +157,11 @@ "CronSchedule": "0/15 * * * * ?" //"CronSchedule": "0 0 23 ? * MON-FRI" // Occurs at 23:00, Monday to Friday" } + }, + "RightToWorkSettings": { + "NationalitiesExempted": [ + "British", + "Irish" + ] } } \ No newline at end of file From 93465909f1e914c1d7a3b578cfc5d075e8cbe5d6 Mon Sep 17 00:00:00 2001 From: Carl Sixsmith Date: Thu, 3 Oct 2024 13:25:48 +0100 Subject: [PATCH 12/27] force fix for the nationality column --- ...2532_Participant_UpdateNationalityLength.cs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20240930142532_Participant_UpdateNationalityLength.cs b/src/Migrators/Migrators.MSSQL/Migrations/20240930142532_Participant_UpdateNationalityLength.cs index 179bc8f4..98348a67 100644 --- a/src/Migrators/Migrators.MSSQL/Migrations/20240930142532_Participant_UpdateNationalityLength.cs +++ b/src/Migrators/Migrators.MSSQL/Migrations/20240930142532_Participant_UpdateNationalityLength.cs @@ -10,31 +10,21 @@ public partial class Participant_UpdateNationalityLength : Migration /// protected override void Up(MigrationBuilder migrationBuilder) { - migrationBuilder.AlterColumn( + migrationBuilder.AddColumn( name: "Nationality", schema: "Participant", table: "Participant", type: "nvarchar(50)", - maxLength: 50, - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(max)", - oldNullable: true); + nullable: true); } /// protected override void Down(MigrationBuilder migrationBuilder) { - migrationBuilder.AlterColumn( + migrationBuilder.DropColumn( name: "Nationality", schema: "Participant", - table: "Participant", - type: "nvarchar(max)", - nullable: true, - oldClrType: typeof(string), - oldType: "nvarchar(50)", - oldMaxLength: 50, - oldNullable: true); + table: "Participant"); } } } From e5c440485f56723e15fd1f41d7029e6cd0a10949 Mon Sep 17 00:00:00 2001 From: Carl Sixsmith Date: Thu, 3 Oct 2024 14:53:42 +0100 Subject: [PATCH 13/27] more removal of broken migrations --- ...601_Participant_AddNationality.Designer.cs | 2725 ----------------- ...240917060601_Participant_AddNationality.cs | 30 - 2 files changed, 2755 deletions(-) delete mode 100644 src/Migrators/Migrators.MSSQL/Migrations/20240917060601_Participant_AddNationality.Designer.cs delete mode 100644 src/Migrators/Migrators.MSSQL/Migrations/20240917060601_Participant_AddNationality.cs diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20240917060601_Participant_AddNationality.Designer.cs b/src/Migrators/Migrators.MSSQL/Migrations/20240917060601_Participant_AddNationality.Designer.cs deleted file mode 100644 index 50af95c1..00000000 --- a/src/Migrators/Migrators.MSSQL/Migrations/20240917060601_Participant_AddNationality.Designer.cs +++ /dev/null @@ -1,2725 +0,0 @@ -// -using System; -using Cfo.Cats.Infrastructure.Persistence; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace Cfo.Cats.Migrators.MSSQL.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20240917060601_Participant_AddNationality")] - partial class Participant_AddNationality - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Contract", b => - { - b.Property("Id") - .HasMaxLength(12) - .HasColumnType("nvarchar(12)"); - - b.Property("Created") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("LotNumber") - .HasColumnType("int"); - - b.Property("_tenantId") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)") - .HasColumnName("TenantId"); - - b.HasKey("Id"); - - b.HasIndex("LotNumber") - .IsUnique(); - - b.HasIndex("_tenantId"); - - b.ToTable("Contract", "Configuration"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Location", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Created") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("_contractId") - .HasMaxLength(12) - .HasColumnType("nvarchar(12)") - .HasColumnName("ContractId"); - - b.Property("_genderProvisionId") - .HasColumnType("int") - .HasColumnName("GenderProvisionId"); - - b.Property("_locationTypeId") - .HasColumnType("int") - .HasColumnName("LocationTypeId"); - - b.Property("_parentLocationId") - .HasColumnType("int") - .HasColumnName("ParentLocationId"); - - b.HasKey("Id"); - - b.HasIndex("_contractId"); - - b.HasIndex("_parentLocationId"); - - b.ToTable("Location", "Configuration"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.LocationMapping", b => - { - b.Property("Code") - .HasMaxLength(3) - .HasColumnType("nvarchar(3)"); - - b.Property("CodeType") - .HasMaxLength(9) - .HasColumnType("nvarchar(9)"); - - b.Property("DeliveryRegion") - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("_locationId") - .HasColumnType("int") - .HasColumnName("LocationId"); - - b.HasKey("Code", "CodeType"); - - b.HasIndex("_locationId"); - - b.ToTable("LocationMapping", "Dms"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Tenant", b => - { - b.Property("Id") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Created") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(150) - .HasColumnType("nvarchar(150)"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.ToTable("Tenant", "Configuration"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Assessments.ParticipantAssessment", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("AssessmentJson") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Completed") - .HasColumnType("datetime2"); - - b.Property("CompletedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("Created") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("EditorId") - .HasColumnType("nvarchar(36)"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("OwnerId") - .HasColumnType("nvarchar(36)"); - - b.Property("ParticipantId") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("nvarchar(9)"); - - b.Property("TenantId") - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.HasIndex("EditorId"); - - b.HasIndex("OwnerId"); - - b.HasIndex("ParticipantId"); - - b.HasIndex("TenantId"); - - b.ToTable("Assessment", "Participant"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.AuditTrail", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("AffectedColumns") - .HasColumnType("nvarchar(max)"); - - b.Property("AuditType") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("DateTime") - .HasColumnType("datetime2"); - - b.Property("NewValues") - .HasColumnType("nvarchar(max)"); - - b.Property("OldValues") - .HasColumnType("nvarchar(max)"); - - b.Property("PrimaryKey") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("TableName") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("nvarchar(36)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("AuditTrail", "Audit"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Bios.ParticipantBio", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("BioJson") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Completed") - .HasColumnType("datetime2"); - - b.Property("CompletedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("Created") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("ParticipantId") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("nvarchar(9)"); - - b.Property("Status") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ParticipantId"); - - b.ToTable("Bio", "Participant"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Documents.Document", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Content") - .HasMaxLength(4000) - .HasColumnType("nvarchar(4000)"); - - b.Property("Created") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("Description") - .HasColumnType("nvarchar(max)"); - - b.Property("DocumentType") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("EditorId") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("IsPublic") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("OwnerId") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("TenantId") - .HasColumnType("nvarchar(50)"); - - b.Property("Title") - .HasColumnType("nvarchar(max)"); - - b.Property("URL") - .HasColumnType("nvarchar(max)"); - - b.Property("Version") - .HasMaxLength(5) - .HasColumnType("nvarchar(5)"); - - b.HasKey("Id"); - - b.HasIndex("CreatedBy"); - - b.HasIndex("LastModifiedBy"); - - b.HasIndex("TenantId"); - - b.ToTable("Document", "Document"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.IdentityAuditTrail", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ActionType") - .IsRequired() - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b.Property("DateTime") - .HasColumnType("datetime2"); - - b.Property("IpAddress") - .HasMaxLength(30) - .HasColumnType("nvarchar(30)"); - - b.Property("PerformedBy") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("UserName") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.HasIndex("UserName", "DateTime") - .HasDatabaseName("idx_IdentityAudit_UserName_DateTime"); - - b.ToTable("IdentityAuditTrail", "Audit"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.KeyValue", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Created") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("Description") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Text") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Value") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.HasKey("Id"); - - b.ToTable("KeyValue", "Configuration"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentEscalationQueueEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Created") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("EditorId") - .HasColumnType("nvarchar(36)"); - - b.Property("IsAccepted") - .HasColumnType("bit"); - - b.Property("IsCompleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("OwnerId") - .HasColumnType("nvarchar(36)"); - - b.Property("ParticipantId") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("nvarchar(9)"); - - b.Property("TenantId") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.HasIndex("EditorId"); - - b.HasIndex("OwnerId"); - - b.HasIndex("ParticipantId"); - - b.HasIndex("TenantId"); - - b.ToTable("EscalationQueue", "Enrolment"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentPqaQueueEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Created") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("EditorId") - .HasColumnType("nvarchar(36)"); - - b.Property("IsAccepted") - .HasColumnType("bit"); - - b.Property("IsCompleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("OwnerId") - .HasColumnType("nvarchar(36)"); - - b.Property("ParticipantId") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("nvarchar(9)"); - - b.Property("TenantId") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.HasIndex("EditorId"); - - b.HasIndex("OwnerId"); - - b.HasIndex("ParticipantId"); - - b.HasIndex("TenantId"); - - b.ToTable("PqaQueue", "Enrolment"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa1QueueEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Created") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("EditorId") - .HasColumnType("nvarchar(36)"); - - b.Property("IsAccepted") - .HasColumnType("bit"); - - b.Property("IsCompleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("OwnerId") - .HasColumnType("nvarchar(36)"); - - b.Property("ParticipantId") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("nvarchar(9)"); - - b.Property("TenantId") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.HasIndex("EditorId"); - - b.HasIndex("OwnerId"); - - b.HasIndex("ParticipantId"); - - b.HasIndex("TenantId"); - - b.ToTable("Qa1Queue", "Enrolment"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa2QueueEntry", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Created") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("EditorId") - .HasColumnType("nvarchar(36)"); - - b.Property("IsAccepted") - .HasColumnType("bit"); - - b.Property("IsCompleted") - .HasColumnType("bit"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b.Property("OwnerId") - .HasColumnType("nvarchar(36)"); - - b.Property("ParticipantId") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("nvarchar(9)"); - - b.Property("TenantId") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.HasKey("Id"); - - b.HasIndex("EditorId"); - - b.HasIndex("OwnerId"); - - b.HasIndex("ParticipantId"); - - b.HasIndex("TenantId"); - - b.ToTable("Qa2Queue", "Enrolment"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Participant", b => - { - b.Property("Id") - .HasMaxLength(9) - .HasColumnType("nvarchar(9)"); - - b.Property("ActiveInFeed") - .HasColumnType("bit"); - - b.Property("AssessmentJustification") - .HasColumnType("nvarchar(max)"); - - b.Property("ConsentStatus") - .HasColumnType("int"); - - b.Property("Created") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("DateOfBirth") - .HasColumnType("date"); - - b.Property("EditorId") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("EnrolmentLocationJustification") - .HasColumnType("nvarchar(max)"); - - b.Property("EnrolmentStatus") - .HasColumnType("int"); - - b.Property("FirstName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Gender") - .HasMaxLength(6) - .HasColumnType("nvarchar(6)"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("LastName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("MiddleName") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Nationality") - .HasColumnType("nvarchar(max)"); - - b.Property("OwnerId") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("ReferralComments") - .HasColumnType("nvarchar(max)"); - - b.Property("ReferralSource") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("RegistrationDetailsJson") - .HasColumnType("nvarchar(max)"); - - b.Property("RiskDue") - .HasColumnType("datetime2"); - - b.Property("_currentLocationId") - .HasColumnType("int") - .HasColumnName("CurrentLocationId"); - - b.Property("_enrolmentLocationId") - .HasColumnType("int") - .HasColumnName("EnrolmentLocationId"); - - b.HasKey("Id"); - - b.HasIndex("EditorId"); - - b.HasIndex("OwnerId"); - - b.HasIndex("_currentLocationId"); - - b.HasIndex("_enrolmentLocationId"); - - b.ToTable("Participant", "Participant"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.ParticipantEnrolmentHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Created") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("EnrolmentStatus") - .HasColumnType("int"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("ParticipantId") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("nvarchar(9)"); - - b.HasKey("Id"); - - b.HasIndex("ParticipantId"); - - b.ToTable("EnrolmentHistory", "Participant"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.PathwayPlan", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("Created") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("ParticipantId") - .IsRequired() - .HasMaxLength(9) - .HasColumnType("nvarchar(9)"); - - b.HasKey("Id"); - - b.HasIndex("ParticipantId"); - - b.ToTable("PathwayPlan", "Participant"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Risk", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b.Property("ActivityRecommendations") - .HasColumnType("nvarchar(max)"); - - b.Property("ActivityRecommendationsReceived") - .HasColumnType("datetime2"); - - b.Property("ActivityRestrictions") - .HasColumnType("nvarchar(max)"); - - b.Property("ActivityRestrictionsReceived") - .HasColumnType("datetime2"); - - b.Property("AdditionalInformation") - .HasColumnType("nvarchar(max)"); - - b.Property("Completed") - .HasColumnType("datetime2"); - - b.Property("CompletedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("Created") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("IsRelevantToCommunity") - .HasColumnType("bit"); - - b.Property("IsRelevantToCustody") - .HasColumnType("bit"); - - b.Property("IsSubjectToSHPO") - .HasColumnType("int"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("LicenseConditions") - .HasColumnType("nvarchar(max)"); - - b.Property("LicenseEnd") - .HasColumnType("datetime2"); - - b.Property("NSDCase") - .HasColumnType("int"); - - b.Property("PSFRestrictions") - .HasColumnType("nvarchar(max)"); - - b.Property("PSFRestrictionsReceived") - .HasColumnType("datetime2"); - - b.Property("ParticipantId") - .IsRequired() - .HasColumnType("nvarchar(9)"); - - b.Property("ReferredOn") - .HasColumnType("datetime2"); - - b.Property("ReferrerEmail") - .HasColumnType("nvarchar(max)"); - - b.Property("ReferrerName") - .HasColumnType("nvarchar(max)"); - - b.Property("RegistrationDetailsJson") - .HasColumnType("nvarchar(max)"); - - b.Property("ReviewJustification") - .HasColumnType("nvarchar(max)"); - - b.Property("ReviewReason") - .HasColumnType("int"); - - b.Property("RiskToChildrenInCommunity") - .HasColumnType("int"); - - b.Property("RiskToChildrenInCustody") - .HasColumnType("int"); - - b.Property("RiskToKnownAdultInCommunity") - .HasColumnType("int"); - - b.Property("RiskToKnownAdultInCustody") - .HasColumnType("int"); - - b.Property("RiskToOtherPrisonersInCustody") - .HasColumnType("int"); - - b.Property("RiskToPublicInCommunity") - .HasColumnType("int"); - - b.Property("RiskToPublicInCustody") - .HasColumnType("int"); - - b.Property("RiskToSelfInCommunity") - .HasColumnType("int"); - - b.Property("RiskToSelfInCustody") - .HasColumnType("int"); - - b.Property("RiskToStaffInCommunity") - .HasColumnType("int"); - - b.Property("RiskToStaffInCustody") - .HasColumnType("int"); - - b.Property("SpecificRisk") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("ParticipantId"); - - b.ToTable("Risk", "Participant"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Timeline", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Created") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .HasColumnType("nvarchar(36)"); - - b.Property("EventType") - .HasColumnType("int"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("Line1") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Line2") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("Line3") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("ParticipantId") - .IsRequired() - .HasColumnType("nvarchar(9)"); - - b.HasKey("Id"); - - b.HasIndex("CreatedBy"); - - b.HasIndex("ParticipantId"); - - b.ToTable("Timeline", "Participant"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRole", b => - { - b.Property("Id") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .IsRequired() - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Name") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("NormalizedName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("RoleRank") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedName") - .IsUnique() - .HasDatabaseName("RoleNameIndex"); - - b.ToTable("Role", "Identity"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRoleClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("Group") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("RoleId") - .IsRequired() - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.HasKey("Id"); - - b.HasIndex("RoleId"); - - b.ToTable("RoleClaim", "Identity"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUser", b => - { - b.Property("Id") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("AccessFailedCount") - .HasColumnType("int"); - - b.Property("ConcurrencyStamp") - .IsConcurrencyToken() - .HasColumnType("nvarchar(max)"); - - b.Property("Created") - .HasColumnType("datetime2"); - - b.Property("CreatedBy") - .IsRequired() - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("DisplayName") - .IsRequired() - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b.Property("Email") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("EmailConfirmed") - .HasColumnType("bit"); - - b.Property("IsActive") - .HasColumnType("bit"); - - b.Property("IsLive") - .HasColumnType("bit"); - - b.Property("LastLogin") - .HasColumnType("datetime2"); - - b.Property("LastModified") - .HasColumnType("datetime2"); - - b.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("LockoutEnabled") - .HasColumnType("bit"); - - b.Property("LockoutEnd") - .HasColumnType("datetimeoffset"); - - b.Property("MemorableDate") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("MemorablePlace") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("NormalizedEmail") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("NormalizedUserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.Property("PasswordHash") - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b.Property("PhoneNumberConfirmed") - .HasColumnType("bit"); - - b.Property("ProfilePictureDataUrl") - .HasColumnType("text"); - - b.Property("ProviderId") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("RefreshToken") - .HasColumnType("nvarchar(max)"); - - b.Property("RefreshTokenExpiryTime") - .HasColumnType("datetime2"); - - b.Property("RequiresPasswordReset") - .HasColumnType("bit"); - - b.Property("SecurityStamp") - .HasColumnType("nvarchar(max)"); - - b.Property("SuperiorId") - .HasColumnType("nvarchar(36)"); - - b.Property("TenantId") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("TenantName") - .IsRequired() - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b.Property("TwoFactorEnabled") - .HasColumnType("bit"); - - b.Property("UserName") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b.HasKey("Id"); - - b.HasIndex("NormalizedEmail") - .HasDatabaseName("EmailIndex"); - - b.HasIndex("NormalizedUserName") - .IsUnique() - .HasDatabaseName("UserNameIndex") - .HasFilter("[NormalizedUserName] IS NOT NULL"); - - b.HasIndex("SuperiorId"); - - b.HasIndex("TenantId"); - - b.ToTable("User", "Identity"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserClaim", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ClaimType") - .HasColumnType("nvarchar(max)"); - - b.Property("ClaimValue") - .HasColumnType("nvarchar(max)"); - - b.Property("Description") - .IsRequired() - .HasMaxLength(200) - .HasColumnType("nvarchar(200)"); - - b.Property("UserId") - .IsRequired() - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("UserClaim", "Identity"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserRole", b => - { - b.Property("UserId") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("RoleId") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.HasKey("UserId", "RoleId"); - - b.HasIndex("RoleId"); - - b.ToTable("UserRole", "Identity"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserToken", b => - { - b.Property("UserId") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("Name") - .HasColumnType("nvarchar(450)"); - - b.Property("Value") - .HasColumnType("nvarchar(max)"); - - b.HasKey("UserId", "LoginProvider", "Name"); - - b.ToTable("UserToken", "Identity"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Identity.PasswordHistory", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("CreatedAt") - .HasColumnType("datetime2"); - - b.Property("PasswordHash") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.HasKey("Id"); - - b.ToTable("PasswordHistory", "Identity"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Identity.UserLogin", b => - { - b.Property("LoginProvider") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderKey") - .HasColumnType("nvarchar(450)"); - - b.Property("ProviderDisplayName") - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .IsRequired() - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b.HasKey("LoginProvider", "ProviderKey"); - - b.HasIndex("UserId"); - - b.ToTable("UserLogin", "Identity"); - }); - - modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("FriendlyName") - .HasColumnType("nvarchar(max)"); - - b.Property("Xml") - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("DataProtectionKeys"); - }); - - modelBuilder.Entity("TenantLocation", b => - { - b.Property("LocationId") - .HasColumnType("int"); - - b.Property("TenantId") - .HasColumnType("nvarchar(50)"); - - b.HasKey("LocationId", "TenantId"); - - b.HasIndex("TenantId"); - - b.ToTable("TenantLocation", "Configuration"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Contract", b => - { - b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") - .WithMany() - .HasForeignKey("_tenantId"); - - b.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b1 => - { - b1.Property("ContractId") - .HasColumnType("nvarchar(12)"); - - b1.Property("EndDate") - .HasColumnType("datetime2") - .HasColumnName("LifetimeEnd"); - - b1.Property("StartDate") - .HasColumnType("datetime2") - .HasColumnName("LifetimeStart"); - - b1.HasKey("ContractId"); - - b1.ToTable("Contract", "Configuration"); - - b1.WithOwner() - .HasForeignKey("ContractId"); - }); - - b.Navigation("Lifetime") - .IsRequired(); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Location", b => - { - b.HasOne("Cfo.Cats.Domain.Entities.Administration.Contract", "Contract") - .WithMany("Locations") - .HasForeignKey("_contractId"); - - b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "ParentLocation") - .WithMany("ChildLocations") - .HasForeignKey("_parentLocationId") - .OnDelete(DeleteBehavior.Restrict); - - b.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b1 => - { - b1.Property("LocationId") - .HasColumnType("int"); - - b1.Property("EndDate") - .HasColumnType("datetime2") - .HasColumnName("LifetimeEnd"); - - b1.Property("StartDate") - .HasColumnType("datetime2") - .HasColumnName("LifetimeStart"); - - b1.HasKey("LocationId"); - - b1.ToTable("Location", "Configuration"); - - b1.WithOwner() - .HasForeignKey("LocationId"); - }); - - b.Navigation("Contract"); - - b.Navigation("Lifetime") - .IsRequired(); - - b.Navigation("ParentLocation"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.LocationMapping", b => - { - b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "Location") - .WithMany("LocationMappings") - .HasForeignKey("_locationId"); - - b.Navigation("Location"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Tenant", b => - { - b.OwnsMany("Cfo.Cats.Domain.ValueObjects.TenantDomain", "Domains", b1 => - { - b1.Property("TenantId") - .HasColumnType("nvarchar(50)"); - - b1.Property("Domain") - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b1.Property("Created") - .HasColumnType("datetime2"); - - b1.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("LastModified") - .HasColumnType("datetime2"); - - b1.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.HasKey("TenantId", "Domain"); - - b1.ToTable("TenantDomain", "Configuration"); - - b1.WithOwner() - .HasForeignKey("TenantId"); - }); - - b.Navigation("Domains"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Assessments.ParticipantAssessment", b => - { - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") - .WithMany() - .HasForeignKey("EditorId"); - - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") - .WithMany() - .HasForeignKey("OwnerId"); - - b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) - .WithMany() - .HasForeignKey("ParticipantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", null) - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade); - - b.OwnsMany("Cfo.Cats.Domain.ValueObjects.PathwayScore", "Scores", b1 => - { - b1.Property("AssessmentId") - .HasColumnType("uniqueidentifier"); - - b1.Property("Pathway") - .HasMaxLength(50) - .HasColumnType("nvarchar(50)"); - - b1.Property("Score") - .HasColumnType("float"); - - b1.HasKey("AssessmentId", "Pathway"); - - b1.ToTable("AssessmentPathwayScore", "Participant"); - - b1.WithOwner() - .HasForeignKey("AssessmentId"); - }); - - b.Navigation("Editor"); - - b.Navigation("Owner"); - - b.Navigation("Scores"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.AuditTrail", b => - { - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.SetNull); - - b.Navigation("Owner"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Bios.ParticipantBio", b => - { - b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) - .WithMany() - .HasForeignKey("ParticipantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Documents.Document", b => - { - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") - .WithMany() - .HasForeignKey("CreatedBy") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") - .WithMany() - .HasForeignKey("LastModifiedBy") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") - .WithMany() - .HasForeignKey("TenantId"); - - b.Navigation("Editor"); - - b.Navigation("Owner"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentEscalationQueueEntry", b => - { - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") - .WithMany() - .HasForeignKey("EditorId"); - - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") - .WithMany() - .HasForeignKey("OwnerId"); - - b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") - .WithMany() - .HasForeignKey("ParticipantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => - { - b1.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); - - b1.Property("CallReference") - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b1.Property("Created") - .HasColumnType("datetime2"); - - b1.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("EnrolmentEscalationQueueEntryId") - .HasColumnType("uniqueidentifier"); - - b1.Property("LastModified") - .HasColumnType("datetime2"); - - b1.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("Message") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b1.Property("TenantId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("Id"); - - b1.HasIndex("CreatedBy"); - - b1.HasIndex("EnrolmentEscalationQueueEntryId"); - - b1.HasIndex("LastModifiedBy"); - - b1.ToTable("EscalationNote", "Enrolment"); - - b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") - .WithMany() - .HasForeignKey("CreatedBy"); - - b1.WithOwner() - .HasForeignKey("EnrolmentEscalationQueueEntryId"); - - b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") - .WithMany() - .HasForeignKey("LastModifiedBy"); - - b1.Navigation("CreatedByUser"); - - b1.Navigation("LastModifiedByUser"); - }); - - b.Navigation("Editor"); - - b.Navigation("Notes"); - - b.Navigation("Owner"); - - b.Navigation("Participant"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentPqaQueueEntry", b => - { - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") - .WithMany() - .HasForeignKey("EditorId"); - - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") - .WithMany() - .HasForeignKey("OwnerId"); - - b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") - .WithMany() - .HasForeignKey("ParticipantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => - { - b1.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); - - b1.Property("CallReference") - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b1.Property("Created") - .HasColumnType("datetime2"); - - b1.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("EnrolmentPqaQueueEntryId") - .HasColumnType("uniqueidentifier"); - - b1.Property("LastModified") - .HasColumnType("datetime2"); - - b1.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("Message") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b1.Property("TenantId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("Id"); - - b1.HasIndex("CreatedBy"); - - b1.HasIndex("EnrolmentPqaQueueEntryId"); - - b1.HasIndex("LastModifiedBy"); - - b1.ToTable("PqaQueueNote", "Enrolment"); - - b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") - .WithMany() - .HasForeignKey("CreatedBy"); - - b1.WithOwner() - .HasForeignKey("EnrolmentPqaQueueEntryId"); - - b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") - .WithMany() - .HasForeignKey("LastModifiedBy"); - - b1.Navigation("CreatedByUser"); - - b1.Navigation("LastModifiedByUser"); - }); - - b.Navigation("Editor"); - - b.Navigation("Notes"); - - b.Navigation("Owner"); - - b.Navigation("Participant"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa1QueueEntry", b => - { - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") - .WithMany() - .HasForeignKey("EditorId"); - - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") - .WithMany() - .HasForeignKey("OwnerId"); - - b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") - .WithMany() - .HasForeignKey("ParticipantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => - { - b1.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); - - b1.Property("CallReference") - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b1.Property("Created") - .HasColumnType("datetime2"); - - b1.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("EnrolmentQa1QueueEntryId") - .HasColumnType("uniqueidentifier"); - - b1.Property("LastModified") - .HasColumnType("datetime2"); - - b1.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("Message") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b1.Property("TenantId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("Id"); - - b1.HasIndex("CreatedBy"); - - b1.HasIndex("EnrolmentQa1QueueEntryId"); - - b1.HasIndex("LastModifiedBy"); - - b1.ToTable("Qa1QueueNote", "Enrolment"); - - b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") - .WithMany() - .HasForeignKey("CreatedBy"); - - b1.WithOwner() - .HasForeignKey("EnrolmentQa1QueueEntryId"); - - b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") - .WithMany() - .HasForeignKey("LastModifiedBy"); - - b1.Navigation("CreatedByUser"); - - b1.Navigation("LastModifiedByUser"); - }); - - b.Navigation("Editor"); - - b.Navigation("Notes"); - - b.Navigation("Owner"); - - b.Navigation("Participant"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa2QueueEntry", b => - { - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") - .WithMany() - .HasForeignKey("EditorId"); - - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") - .WithMany() - .HasForeignKey("OwnerId"); - - b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") - .WithMany() - .HasForeignKey("ParticipantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => - { - b1.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); - - b1.Property("CallReference") - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b1.Property("Created") - .HasColumnType("datetime2"); - - b1.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("EnrolmentQa2QueueEntryId") - .HasColumnType("uniqueidentifier"); - - b1.Property("LastModified") - .HasColumnType("datetime2"); - - b1.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("Message") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b1.Property("TenantId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("Id"); - - b1.HasIndex("CreatedBy"); - - b1.HasIndex("EnrolmentQa2QueueEntryId"); - - b1.HasIndex("LastModifiedBy"); - - b1.ToTable("Qa2QueueNote", "Enrolment"); - - b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") - .WithMany() - .HasForeignKey("CreatedBy"); - - b1.WithOwner() - .HasForeignKey("EnrolmentQa2QueueEntryId"); - - b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") - .WithMany() - .HasForeignKey("LastModifiedBy"); - - b1.Navigation("CreatedByUser"); - - b1.Navigation("LastModifiedByUser"); - }); - - b.Navigation("Editor"); - - b.Navigation("Notes"); - - b.Navigation("Owner"); - - b.Navigation("Participant"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Participant", b => - { - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") - .WithMany() - .HasForeignKey("EditorId"); - - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") - .WithMany() - .HasForeignKey("OwnerId"); - - b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "CurrentLocation") - .WithMany() - .HasForeignKey("_currentLocationId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired() - .HasConstraintName("FK_Participant_Location"); - - b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "EnrolmentLocation") - .WithMany() - .HasForeignKey("_enrolmentLocationId") - .HasConstraintName("FK_Participant_EnrolmentLocation"); - - b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.Consent", "Consents", b1 => - { - b1.Property("ParticipantId") - .HasColumnType("nvarchar(9)"); - - b1.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); - - b1.Property("Created") - .HasColumnType("datetime2"); - - b1.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("LastModified") - .HasColumnType("datetime2"); - - b1.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("_documentId") - .HasColumnType("uniqueidentifier") - .HasColumnName("DocumentId"); - - b1.HasKey("ParticipantId", "Id"); - - b1.HasIndex("_documentId"); - - b1.ToTable("Consent", "Participant"); - - b1.WithOwner() - .HasForeignKey("ParticipantId"); - - b1.HasOne("Cfo.Cats.Domain.Entities.Documents.Document", "Document") - .WithMany() - .HasForeignKey("_documentId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b1.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b2 => - { - b2.Property("ConsentParticipantId") - .HasColumnType("nvarchar(9)"); - - b2.Property("ConsentId") - .HasColumnType("int"); - - b2.Property("EndDate") - .HasColumnType("datetime2") - .HasColumnName("ValidTo"); - - b2.Property("StartDate") - .HasColumnType("datetime2") - .HasColumnName("ValidFrom"); - - b2.HasKey("ConsentParticipantId", "ConsentId"); - - b2.ToTable("Consent", "Participant"); - - b2.WithOwner() - .HasForeignKey("ConsentParticipantId", "ConsentId"); - }); - - b1.Navigation("Document"); - - b1.Navigation("Lifetime") - .IsRequired(); - }); - - b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.ExternalIdentifier", "ExternalIdentifiers", b1 => - { - b1.Property("Value") - .HasMaxLength(16) - .HasColumnType("nvarchar(16)"); - - b1.Property("Type") - .HasColumnType("int"); - - b1.Property("ParticipantId") - .HasColumnType("nvarchar(9)"); - - b1.HasKey("Value", "Type", "ParticipantId"); - - b1.HasIndex("ParticipantId"); - - b1.ToTable("ExternalIdentifier", "Participant"); - - b1.WithOwner() - .HasForeignKey("ParticipantId"); - }); - - b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => - { - b1.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); - - b1.Property("CallReference") - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b1.Property("Created") - .HasColumnType("datetime2"); - - b1.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("LastModified") - .HasColumnType("datetime2"); - - b1.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("Message") - .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b1.Property("ParticipantId") - .IsRequired() - .HasColumnType("nvarchar(9)"); - - b1.Property("TenantId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.HasKey("Id"); - - b1.HasIndex("CreatedBy"); - - b1.HasIndex("LastModifiedBy"); - - b1.HasIndex("ParticipantId"); - - b1.ToTable("Note", "Participant"); - - b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") - .WithMany() - .HasForeignKey("CreatedBy"); - - b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") - .WithMany() - .HasForeignKey("LastModifiedBy"); - - b1.WithOwner() - .HasForeignKey("ParticipantId"); - - b1.Navigation("CreatedByUser"); - - b1.Navigation("LastModifiedByUser"); - }); - - b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.RightToWork", "RightToWorks", b1 => - { - b1.Property("ParticipantId") - .HasColumnType("nvarchar(9)"); - - b1.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); - - b1.Property("Created") - .HasColumnType("datetime2"); - - b1.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("LastModified") - .HasColumnType("datetime2"); - - b1.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("_documentId") - .HasColumnType("uniqueidentifier") - .HasColumnName("DocumentId"); - - b1.HasKey("ParticipantId", "Id"); - - b1.HasIndex("_documentId"); - - b1.ToTable("RightToWork", "Participant"); - - b1.WithOwner() - .HasForeignKey("ParticipantId"); - - b1.HasOne("Cfo.Cats.Domain.Entities.Documents.Document", "Document") - .WithMany() - .HasForeignKey("_documentId"); - - b1.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b2 => - { - b2.Property("RightToWorkParticipantId") - .HasColumnType("nvarchar(9)"); - - b2.Property("RightToWorkId") - .HasColumnType("int"); - - b2.Property("EndDate") - .HasColumnType("datetime2") - .HasColumnName("ValidTo"); - - b2.Property("StartDate") - .HasColumnType("datetime2") - .HasColumnName("ValidFrom"); - - b2.HasKey("RightToWorkParticipantId", "RightToWorkId"); - - b2.ToTable("RightToWork", "Participant"); - - b2.WithOwner() - .HasForeignKey("RightToWorkParticipantId", "RightToWorkId"); - }); - - b1.Navigation("Document"); - - b1.Navigation("Lifetime") - .IsRequired(); - }); - - b.OwnsOne("Cfo.Cats.Domain.Entities.Participants.Supervisor", "Supervisor", b1 => - { - b1.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b1.Property("Address") - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); - - b1.Property("Created") - .HasColumnType("datetime2"); - - b1.Property("CreatedBy") - .HasColumnType("nvarchar(max)"); - - b1.Property("EmailAddress") - .HasMaxLength(100) - .HasColumnType("nvarchar(100)"); - - b1.Property("LastModified") - .HasColumnType("datetime2"); - - b1.Property("LastModifiedBy") - .HasColumnType("nvarchar(max)"); - - b1.Property("MobileNumber") - .HasMaxLength(16) - .HasColumnType("nvarchar(16)"); - - b1.Property("Name") - .HasMaxLength(128) - .HasColumnType("nvarchar(128)"); - - b1.Property("ParticipantId") - .IsRequired() - .HasColumnType("nvarchar(9)"); - - b1.Property("TelephoneNumber") - .HasMaxLength(16) - .HasColumnType("nvarchar(16)"); - - b1.HasKey("Id"); - - b1.HasIndex("ParticipantId") - .IsUnique(); - - b1.ToTable("Supervisor", "Participant"); - - b1.WithOwner() - .HasForeignKey("ParticipantId"); - }); - - b.Navigation("Consents"); - - b.Navigation("CurrentLocation"); - - b.Navigation("Editor"); - - b.Navigation("EnrolmentLocation"); - - b.Navigation("ExternalIdentifiers"); - - b.Navigation("Notes"); - - b.Navigation("Owner"); - - b.Navigation("RightToWorks"); - - b.Navigation("Supervisor"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.PathwayPlan", b => - { - b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.Objective", "Objectives", b1 => - { - b1.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b1.Property("Completed") - .HasColumnType("datetime2"); - - b1.Property("CompletedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("CompletedStatus") - .HasColumnType("int"); - - b1.Property("Created") - .HasColumnType("datetime2"); - - b1.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("Description") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("Index") - .HasColumnType("int"); - - b1.Property("Justification") - .HasColumnType("nvarchar(max)"); - - b1.Property("LastModified") - .HasColumnType("datetime2"); - - b1.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("PathwayPlanId") - .HasColumnType("uniqueidentifier"); - - b1.HasKey("Id"); - - b1.HasIndex("CompletedBy"); - - b1.HasIndex("PathwayPlanId"); - - b1.ToTable("Objective", "Participant"); - - b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CompletedByUser") - .WithMany() - .HasForeignKey("CompletedBy"); - - b1.WithOwner() - .HasForeignKey("PathwayPlanId"); - - b1.OwnsMany("Cfo.Cats.Domain.Entities.Participants.ObjectiveTask", "Tasks", b2 => - { - b2.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b2.Property("Completed") - .HasColumnType("datetime2"); - - b2.Property("CompletedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b2.Property("CompletedStatus") - .HasColumnType("int"); - - b2.Property("Created") - .HasColumnType("datetime2"); - - b2.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b2.Property("Description") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b2.Property("Due") - .HasColumnType("datetime2"); - - b2.Property("Index") - .HasColumnType("int"); - - b2.Property("Justification") - .HasColumnType("nvarchar(max)"); - - b2.Property("LastModified") - .HasColumnType("datetime2"); - - b2.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b2.Property("ObjectiveId") - .HasColumnType("uniqueidentifier"); - - b2.HasKey("Id"); - - b2.HasIndex("CompletedBy"); - - b2.HasIndex("ObjectiveId"); - - b2.ToTable("ObjectiveTask", "Participant"); - - b2.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CompletedByUser") - .WithMany() - .HasForeignKey("CompletedBy"); - - b2.WithOwner() - .HasForeignKey("ObjectiveId"); - - b2.Navigation("CompletedByUser"); - }); - - b1.Navigation("CompletedByUser"); - - b1.Navigation("Tasks"); - }); - - b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.PathwayPlanReviewHistory", "ReviewHistories", b1 => - { - b1.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("uniqueidentifier"); - - b1.Property("Created") - .HasColumnType("datetime2"); - - b1.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("LastModified") - .HasColumnType("datetime2"); - - b1.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("PathwayPlanId") - .HasColumnType("uniqueidentifier"); - - b1.HasKey("Id"); - - b1.HasIndex("PathwayPlanId"); - - b1.ToTable("PathwayPlanReviewHistory", "Participant"); - - b1.WithOwner() - .HasForeignKey("PathwayPlanId"); - }); - - b.Navigation("Objectives"); - - b.Navigation("ReviewHistories"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Risk", b => - { - b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") - .WithMany() - .HasForeignKey("ParticipantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Participant"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Timeline", b => - { - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") - .WithMany() - .HasForeignKey("CreatedBy") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) - .WithMany() - .HasForeignKey("ParticipantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("CreatedByUser"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRoleClaim", b => - { - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationRole", "Role") - .WithMany("RoleClaims") - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Role"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUser", b => - { - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Superior") - .WithMany() - .HasForeignKey("SuperiorId"); - - b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => - { - b1.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); - - b1.Property("CallReference") - .HasMaxLength(20) - .HasColumnType("nvarchar(20)"); - - b1.Property("Created") - .HasColumnType("datetime2"); - - b1.Property("CreatedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("LastModified") - .HasColumnType("datetime2"); - - b1.Property("LastModifiedBy") - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.Property("Message") - .IsRequired() - .HasMaxLength(255) - .HasColumnType("nvarchar(255)"); - - b1.Property("TenantId") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b1.Property("UserId") - .IsRequired() - .HasMaxLength(36) - .HasColumnType("nvarchar(36)"); - - b1.HasKey("Id"); - - b1.HasIndex("CreatedBy"); - - b1.HasIndex("LastModifiedBy"); - - b1.HasIndex("UserId"); - - b1.ToTable("Note", "Identity"); - - b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") - .WithMany() - .HasForeignKey("CreatedBy"); - - b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") - .WithMany() - .HasForeignKey("LastModifiedBy"); - - b1.WithOwner() - .HasForeignKey("UserId"); - - b1.Navigation("CreatedByUser"); - - b1.Navigation("LastModifiedByUser"); - }); - - b.Navigation("Notes"); - - b.Navigation("Superior"); - - b.Navigation("Tenant"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserClaim", b => - { - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") - .WithMany("UserClaims") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserRole", b => - { - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationRole", "Role") - .WithMany("UserRoles") - .HasForeignKey("RoleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") - .WithMany("UserRoles") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Role"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserToken", b => - { - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") - .WithMany("Tokens") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Identity.UserLogin", b => - { - b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") - .WithMany("Logins") - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("TenantLocation", b => - { - b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", null) - .WithMany() - .HasForeignKey("LocationId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", null) - .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Contract", b => - { - b.Navigation("Locations"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Location", b => - { - b.Navigation("ChildLocations"); - - b.Navigation("LocationMappings"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRole", b => - { - b.Navigation("RoleClaims"); - - b.Navigation("UserRoles"); - }); - - modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUser", b => - { - b.Navigation("Logins"); - - b.Navigation("Tokens"); - - b.Navigation("UserClaims"); - - b.Navigation("UserRoles"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20240917060601_Participant_AddNationality.cs b/src/Migrators/Migrators.MSSQL/Migrations/20240917060601_Participant_AddNationality.cs deleted file mode 100644 index c9922372..00000000 --- a/src/Migrators/Migrators.MSSQL/Migrations/20240917060601_Participant_AddNationality.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace Cfo.Cats.Migrators.MSSQL.Migrations -{ - /// - public partial class Participant_AddNationality : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.AddColumn( - name: "Nationality", - schema: "Participant", - table: "Participant", - type: "nvarchar(max)", - nullable: true); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropColumn( - name: "Nationality", - schema: "Participant", - table: "Participant"); - } - } -} From 63fa4a4ca7df5483dd11b5d34cf4e7a744f7fc61 Mon Sep 17 00:00:00 2001 From: Carl Sixsmith Date: Wed, 2 Oct 2024 13:40:15 +0100 Subject: [PATCH 14/27] CFODEV-764: Display other peoples participants. - User can select to view all Participants - User can filter by one or more locations --- .../ParticipantAdvancedFilter.cs | 19 +++++++ .../ParticipantAdvancedSpecification.cs | 13 ++--- .../Pages/Participants/Participants.razor | 52 +++++++++++++++++-- 3 files changed, 74 insertions(+), 10 deletions(-) diff --git a/src/Application/Features/Participants/Specifications/ParticipantAdvancedFilter.cs b/src/Application/Features/Participants/Specifications/ParticipantAdvancedFilter.cs index eec6ea47..9c5ca8fc 100644 --- a/src/Application/Features/Participants/Specifications/ParticipantAdvancedFilter.cs +++ b/src/Application/Features/Participants/Specifications/ParticipantAdvancedFilter.cs @@ -5,8 +5,27 @@ namespace Cfo.Cats.Application.Features.Participants.Specifications; public class ParticipantAdvancedFilter : PaginationFilter { + /// + /// The filter for the list (based on the status) + /// public ParticipantListView ListView { get; set; } = ParticipantListView.Default; + + /// + /// The currently logged in user + /// public UserProfile? CurrentUser { get; set; } + + /// + /// Flag to indicate that you only want to see your own cases. + /// + [Description("Just My Cases")] + public bool JustMyCases { get; set; } = true; + + /// + /// The current location of the participant + /// + public int[] Locations { get; set; } = []; + } public enum ParticipantListView diff --git a/src/Application/Features/Participants/Specifications/ParticipantAdvancedSpecification.cs b/src/Application/Features/Participants/Specifications/ParticipantAdvancedSpecification.cs index 69b1a0d7..b2e8fdd3 100644 --- a/src/Application/Features/Participants/Specifications/ParticipantAdvancedSpecification.cs +++ b/src/Application/Features/Participants/Specifications/ParticipantAdvancedSpecification.cs @@ -21,14 +21,15 @@ public ParticipantAdvancedSpecification(ParticipantAdvancedFilter filter) Query.Where( p => p.EnrolmentStatus == EnrolmentStatus.ArchivedStatus.Value, filter.ListView == ParticipantListView.Archived); - Query.Where( - p => p.OwnerId == filter.CurrentUser!.UserId, - filter.CurrentUser!.AssignedRoles is []) + Query.Where(p => p.OwnerId == filter.CurrentUser!.UserId, filter.JustMyCases) .Where(p => p.Owner!.TenantId!.StartsWith(filter.CurrentUser!.TenantId!)) + .Where(p => filter.Locations.Contains(p.CurrentLocation.Id), filter.Locations is not []) .Where( - // if we have passed a filter through, search the surname - p => p.LastName!.Contains(filter.Keyword!) || p.CurrentLocation.Name.Contains(filter.Keyword!) || p.Id.Contains(filter.Keyword!) - , string.IsNullOrEmpty(filter.Keyword) == false); + // if we have passed a filter through, search the surname and current location + p => p.LastName!.Contains(filter.Keyword!) + || p.CurrentLocation.Name.Contains(filter.Keyword!) + || p.Id.Contains(filter.Keyword!), + string.IsNullOrEmpty(filter.Keyword) == false); } diff --git a/src/Server.UI/Pages/Participants/Participants.razor b/src/Server.UI/Pages/Participants/Participants.razor index fc1e7a13..ef89a6f7 100644 --- a/src/Server.UI/Pages/Participants/Participants.razor +++ b/src/Server.UI/Pages/Participants/Participants.razor @@ -1,4 +1,6 @@ @page "/pages/participants" +@using Cfo.Cats.Application.Common.Interfaces.Locations +@using Cfo.Cats.Application.Features.Locations.DTOs @using Cfo.Cats.Domain.Common.Enums @using Cfo.Cats.Server.UI.Pages.Participants.Components @using Cfo.Cats.Application.Features.Participants.Caching @@ -40,6 +42,26 @@ +
+ + + @foreach (var item in Locations!) + { + + + @item.Name + + } + + +
+
+ +
@@ -189,16 +211,21 @@ @code { + [Inject] + public ILocationService LocationService {get;set;} = default!; + public string? Title { get; private set; } private int _defaultPageSize = 15; - + + public LocationDto[] Locations { get; set; } = []; + private HashSet _selectedItems = new(); private MudDataGrid _table = default!; private bool _loading; private bool _canSearch; private bool _canEnrol; - + private ParticipantPaginationDto _currentDto = new() { Id = "" }; private ParticipantsWithPagination.Query Query { get; set; } = new(); @@ -207,7 +234,18 @@ { Navigation.NavigateTo($"/pages/enrolments/{participant.Id}"); } - + + private string GetMultiSelectionText(List selectedValues) + { + return $"{selectedValues.Count} location{(selectedValues.Count > 1 ? "s have":" has")} been selected"; + } + + private async Task LocationValuesChanged(IEnumerable selectedValues) + { + Query.Locations = selectedValues.Select(l => l.Id).ToArray(); + await _table.ReloadServerData(); + } + private void Edit(ParticipantPaginationDto participant) { Navigation.NavigateTo($"/pages/participants/{participant.Id}"); @@ -216,6 +254,11 @@ [CascadingParameter] private Task AuthState { get; set; } = default!; [CascadingParameter] private UserProfile? UserProfile { get; set; } + private async Task OnShowEveryoneChanged(bool value) + { + Query.JustMyCases = value; + await _table.ReloadServerData(); + } protected override async Task OnInitializedAsync() { @@ -223,6 +266,7 @@ var state = await AuthState; _canSearch = (await AuthService.AuthorizeAsync(state.User, SecurityPolicies.CandidateSearch)).Succeeded; _canEnrol = (await AuthService.AuthorizeAsync(state.User, SecurityPolicies.Enrol)).Succeeded; + Locations = LocationService.GetVisibleLocations(UserProfile!.TenantId!).OrderByDescending(l => l.LocationType.IsCustody).ThenBy(l => l.Name).ToArray(); } private async Task> ServerReload(GridState state) @@ -260,7 +304,7 @@ Query.ListView = listview; await _table.ReloadServerData(); } - + private async Task OnRefresh() { ParticipantCacheKey.Refresh(); From f809165c1c211c040d274bbd984f6034a5d62b09 Mon Sep 17 00:00:00 2001 From: Carl Sixsmith Date: Fri, 4 Oct 2024 14:09:43 +0100 Subject: [PATCH 15/27] Added Ability to reassign a case to new assignee. Added changes that were requested --- .../Commands/ReassignParticipants.cs | 87 +++++ .../SecurityConstants/SecurityPolicies.cs | 6 +- .../Constants/ConstantString.cs | 5 +- src/Infrastructure/DependencyInjection.cs | 34 +- .../Pages/Identity/Users/Users.razor | 18 +- .../Participants/ReassignParticipant.razor | 330 ++++++++++++++++++ .../Services/Navigation/MenuService.cs | 14 +- 7 files changed, 461 insertions(+), 33 deletions(-) create mode 100644 src/Application/Features/Participants/Commands/ReassignParticipants.cs create mode 100644 src/Server.UI/Pages/Participants/ReassignParticipant.razor diff --git a/src/Application/Features/Participants/Commands/ReassignParticipants.cs b/src/Application/Features/Participants/Commands/ReassignParticipants.cs new file mode 100644 index 00000000..1dc82ddf --- /dev/null +++ b/src/Application/Features/Participants/Commands/ReassignParticipants.cs @@ -0,0 +1,87 @@ +using Cfo.Cats.Application.Common.Security; +using Cfo.Cats.Application.Common.Validators; +using Cfo.Cats.Application.SecurityConstants; + +namespace Cfo.Cats.Application.Features.Participants.Commands +{ + public static class ReassignParticipants + { + [RequestAuthorize(Policy = SecurityPolicies.UserHasAdditionalRoles)] + public class Command : IRequest> + { + public List ParticipantIdsToReassign { get; set; } = new(); + + public UserProfile? CurrentUser { get; set; } + + public required string AssigneeId { get; set; } + } + + public class Handler(IUnitOfWork unitOfWork) : IRequestHandler> + { + public async Task> Handle(Command request, CancellationToken cancellationToken) + { + foreach (var participantId in request.ParticipantIdsToReassign) + { + var participant = await unitOfWork.DbContext.Participants + .FirstOrDefaultAsync(x => x.Id == participantId); + + if (participant is not null) + { + participant.AssignTo(request.AssigneeId); + } + else + { + return Result.Failure("Participant not found"); + } + } + + return Result.Success(true); + } + } + + public class A_ParticipantExists : AbstractValidator + { + private readonly IUnitOfWork _unitOfWork; + + public A_ParticipantExists(IUnitOfWork unitOfWork) + { + _unitOfWork = unitOfWork; + + // Validate each ParticipantId in the list + RuleForEach(p => p.ParticipantIdsToReassign) + .NotNull() + .Length(9) + .WithMessage("Invalid Participant Id") + .MustAsync(Exist) + .WithMessage("Participant does not exist") + .Matches(ValidationConstants.AlphaNumeric) + .WithMessage(string.Format(ValidationConstants.AlphaNumericMessage, "Participant Id")); + } + + // Check if the participant exists in the database + private async Task Exist(string participantId, CancellationToken cancellationToken) + => await _unitOfWork.DbContext.Participants.AnyAsync(p => p.Id == participantId, cancellationToken); + } + + public class B_AssignerHasAccessToAssignee : AbstractValidator + { + private IUnitOfWork _unitOfWork; + public B_AssignerHasAccessToAssignee(IUnitOfWork unitOfWork) + { + _unitOfWork = unitOfWork; + + RuleFor(c => c) + .MustAsync(ValidAssignee) + .WithMessage("This assessment is created by you hence must not be processed at PQA stage by you"); + } + + private async Task ValidAssignee(Command c, CancellationToken cancellationToken) + { + return await _unitOfWork.DbContext.Users.Where(x => x.TenantId!.StartsWith(c.CurrentUser!.TenantId!) + && x.Id == c.CurrentUser.UserId + && x.IsActive == true + ).AnyAsync(cancellationToken); + } + } + } +} \ No newline at end of file diff --git a/src/Application/SecurityConstants/SecurityPolicies.cs b/src/Application/SecurityConstants/SecurityPolicies.cs index 2b09979f..3f34a1a6 100644 --- a/src/Application/SecurityConstants/SecurityPolicies.cs +++ b/src/Application/SecurityConstants/SecurityPolicies.cs @@ -41,5 +41,9 @@ public static class SecurityPolicies public const string SystemFunctionsRead = nameof(SystemFunctionsRead); public const string SystemFunctionsWrite = nameof(SystemFunctionsWrite); - + + /// + /// The used anywhere any user > support worker can do it + /// + public const string UserHasAdditionalRoles = nameof(UserHasAdditionalRoles); } diff --git a/src/Infrastructure/Constants/ConstantString.cs b/src/Infrastructure/Constants/ConstantString.cs index 0dd2f90d..4a2e6788 100644 --- a/src/Infrastructure/Constants/ConstantString.cs +++ b/src/Infrastructure/Constants/ConstantString.cs @@ -124,4 +124,7 @@ public static string Localize(string key) Localize("Right To Work"); public static string AddConsent => Localize("Add Consent"); -} + + public static string ReassignParticipant => + Localize("Reassign Participant"); +} \ No newline at end of file diff --git a/src/Infrastructure/DependencyInjection.cs b/src/Infrastructure/DependencyInjection.cs index 93ae2a85..37303a4f 100644 --- a/src/Infrastructure/DependencyInjection.cs +++ b/src/Infrastructure/DependencyInjection.cs @@ -78,8 +78,7 @@ private static IServiceCollection AddDatabase( IConfiguration configuration ) { - services.AddScoped(); - + services.AddScoped(); if (configuration.GetValue("UseInMemoryDatabase")) { @@ -89,15 +88,13 @@ IConfiguration configuration }); } else - { - + { services.AddDbContext( (p, m) => { var databaseSettings = p.GetRequiredService>().Value; m.AddInterceptors(p.GetServices()); m.UseDatabase(databaseSettings.DbProvider, databaseSettings.ConnectionString); }); - } services.AddDbContextFactory((serviceProvider, optionsBuilder) => @@ -106,8 +103,7 @@ IConfiguration configuration optionsBuilder.AddInterceptors(serviceProvider.GetServices()); optionsBuilder.UseDatabase(databaseSettings.DbProvider, databaseSettings.ConnectionString); }, ServiceLifetime.Scoped); - - + services.AddScoped(); services.AddScoped(); services.AddScoped(); @@ -171,8 +167,7 @@ private static IServiceCollection AddServices(this IServiceCollection services, var options = configuration.GetAWSOptions(); options.Credentials = new BasicAWSCredentials(section.GetRequiredValue("AccessKey"), section.GetRequiredValue("SecretKey")); services.AddDefaultAWSOptions(options); - services.AddAWSService(); - + services.AddAWSService(); } if(configuration.GetValue("UseDummyCandidateService")) @@ -203,7 +198,6 @@ private static IServiceCollection AddServices(this IServiceCollection services, private static IServiceCollection AddAuthenticationService(this IServiceCollection services, IConfiguration configuration) { - services.Configure(configuration.GetSection(nameof(AllowlistOptions))); services @@ -219,7 +213,6 @@ private static IServiceCollection AddAuthenticationService(this IServiceCollecti services.AddScoped, CustomSigninManager>(); services.AddScoped>(); - services.Configure(options => { var identitySettings = configuration .GetRequiredSection(IdentitySettings.Key) @@ -255,8 +248,7 @@ private static IServiceCollection AddAuthenticationService(this IServiceCollecti options.AddPolicy(SecurityPolicies.Export, policy => { policy.RequireAuthenticatedUser(); policy.RequireClaim(ApplicationClaimTypes.AccountLocked, "False"); - policy.RequireRole(RoleNames.SystemSupport, RoleNames.SMT, RoleNames.QAManager); - + policy.RequireRole(RoleNames.SystemSupport, RoleNames.SMT, RoleNames.QAManager); }); options.AddPolicy(SecurityPolicies.CandidateSearch, policy => { @@ -308,7 +300,7 @@ private static IServiceCollection AddAuthenticationService(this IServiceCollecti { policy.RequireAuthenticatedUser(); policy.RequireClaim(ApplicationClaimTypes.AccountLocked, "False"); - policy.RequireRole(RoleNames.SystemSupport, RoleNames.SMT, RoleNames.QAManager, RoleNames.QASupportManager, RoleNames.QAOfficer); + policy.RequireRole(RoleNames.SystemSupport, RoleNames.SMT, RoleNames.QAManager, RoleNames.QAOfficer, RoleNames.QASupportManager); }); options.AddPolicy(SecurityPolicies.Qa2, policy => @@ -318,6 +310,12 @@ private static IServiceCollection AddAuthenticationService(this IServiceCollecti policy.RequireRole(RoleNames.SystemSupport, RoleNames.SMT, RoleNames.QAManager, RoleNames.QASupportManager); }); + options.AddPolicy(SecurityPolicies.UserHasAdditionalRoles, policy => + { + policy.RequireAuthenticatedUser(); + policy.RequireClaim(ApplicationClaimTypes.AccountLocked, "False"); + policy.RequireRole(RoleNames.SystemSupport, RoleNames.SMT, RoleNames.QAManager, RoleNames.QAOfficer, RoleNames.QASupportManager, RoleNames.QAFinance); + }); }) .AddAuthentication(options => { options.DefaultScheme = IdentityConstants.ApplicationScheme; @@ -333,8 +331,7 @@ private static IServiceCollection AddAuthenticationService(this IServiceCollecti if(configuration["IdentitySettings:SecureCookies"] is not null && configuration["IdentitySettings:SecureCookies"]!.Equals("True", StringComparison.CurrentCultureIgnoreCase)) { policy = CookieSecurePolicy.Always; - } - + } services.ConfigureApplicationCookie(options => { options.LoginPath = "/pages/authentication/login"; @@ -348,8 +345,7 @@ private static IServiceCollection AddAuthenticationService(this IServiceCollecti var service = sp.GetRequiredService(); service.Initialize(); return service; - }); - + }); return services; } @@ -434,4 +430,4 @@ private static IServiceCollection AddFusionCacheService(this IServiceCollection ); return services; } -} +} \ No newline at end of file diff --git a/src/Server.UI/Pages/Identity/Users/Users.razor b/src/Server.UI/Pages/Identity/Users/Users.razor index 895456db..78b77c07 100644 --- a/src/Server.UI/Pages/Identity/Users/Users.razor +++ b/src/Server.UI/Pages/Identity/Users/Users.razor @@ -55,7 +55,7 @@ @L[_currentDto.GetClassDescription()] @L["ALL"] - @foreach (var item in TenantsService.DataSource.OrderBy(t => t.Id)) + @foreach (var item in TenantsService.DataSource.Where(x => x.Id.StartsWith(CurrentUser!.TenantId!)).OrderBy(t => t.Id)) { @item.Name } @@ -186,8 +186,7 @@ { @L["Unlock"] } - } - + } } else @@ -442,7 +441,10 @@ x.DisplayName!.Contains(_searchString) || x.PhoneNumber!.Contains(_searchString) && (_searchRole == null || (_searchRole != null && x.UserRoles.Any(x => x.Role.Name == _searchRole))) && - (_selectedTenantId == " " || (_selectedTenantId != " " && x.TenantId == _selectedTenantId))); + (_selectedTenantId == " " + || (_selectedTenantId != " " + && x.TenantId == _selectedTenantId) + )); } private async Task> ServerReload(GridState state) @@ -451,12 +453,14 @@ { _loading = true; - var query = UserManager.Users.Where(CreateSearchPredicate()); + var query = UserManager.Users.Where(CreateSearchPredicate()) ; var items = await query + .Where(x => x.TenantId!.StartsWith(CurrentUser!.TenantId!)) .Include(x => x.UserRoles) - .Include(x => x.Superior) + .Include(x => x.Superior) .EfOrderBySortDefinitions(state) - .Skip(state.Page * state.PageSize).Take(state.PageSize).ProjectTo(Mapper.ConfigurationProvider).ToListAsync(); + .Skip(state.Page * state.PageSize).Take(state.PageSize) + .ProjectTo(Mapper.ConfigurationProvider).ToListAsync(); var total = await UserManager.Users.CountAsync(CreateSearchPredicate()); return new GridData { TotalItems = total, Items = items }; } diff --git a/src/Server.UI/Pages/Participants/ReassignParticipant.razor b/src/Server.UI/Pages/Participants/ReassignParticipant.razor new file mode 100644 index 00000000..f5c293b3 --- /dev/null +++ b/src/Server.UI/Pages/Participants/ReassignParticipant.razor @@ -0,0 +1,330 @@ +@page "/pages/participants/Reassign" + +@using Cfo.Cats.Application.Common.Interfaces.MultiTenant +@using Cfo.Cats.Application.Features.Identity.DTOs +@using Cfo.Cats.Application.Features.Participants.Commands +@using Cfo.Cats.Domain.Common.Enums +@using Cfo.Cats.Domain.Identity +@using Cfo.Cats.Server.UI.Pages.Participants.Components +@using Cfo.Cats.Application.Features.Participants.Caching +@using Cfo.Cats.Application.Features.Participants.DTOs +@using Cfo.Cats.Application.Features.Participants.Queries +@using Cfo.Cats.Application.Features.Participants.Specifications +@using Cfo.Cats.Application.SecurityConstants +@using System.Linq.Expressions + +@inject IStringLocalizer L +@inject ITenantService TenantsService + +@inherits CatsComponentBase + +@attribute [Authorize(Policy = SecurityPolicies.AuthorizedUser)] +@attribute [Authorize(Policy = SecurityPolicies.UserHasAdditionalRoles)] + +@Title + + + + +
+
+ +
+ @ConstantString.ReassignParticipant + + +
+
+
+ @if (_canReassignParticipant) + { +
+ +
+ Select New Assignee +
+ +
+ + @L["Please Select Assignee"] + @foreach (var item in UserManager.Users.Where(x => x.TenantId!.StartsWith(UserProfile!.TenantId!))) + { + @item.NormalizedUserName + } + +
+ +
+ + @ConstantString.ReassignParticipant + +
+
+ } + +
+
+
+ + + + @ConstantString.Refresh + + + + + +
+ @if (_canSearch) + { + + + } +
+
+
+ + + + + + + + + + +
+ @context.Item.ParticipantName + @context.Item.Id +
+
+
+ + + +
+
+ +
+
+
+
+ + + +
+
+ +
+
+
+
+ + + +
+ @if (context.Item.CurrentLocation.LocationType.IsCustody) + { + + } + else + { + + } + @context.Item.CurrentLocation.Name +
+
+
+ + + +
+ @if (context.Item.EnrolmentLocation is not null) + { + @if (context.Item.EnrolmentLocation.LocationType.IsCustody) + { + + } + else + { + + } + @context.Item.EnrolmentLocation?.Name + } +
+
+
+ + + +
+ @context.Item.Owner + @context.Item.Tenant +
+
+
+
+ + + @ConstantString.NoRecords + + + + @ConstantString.Loading + + + + + +
+ +@code { + private UserManager UserManager = null!; + + + public string? Title { get; private set; } + private int _defaultPageSize = 15; + + private HashSet _selectedItems = new(); + + private MudDataGrid _table = default!; + private bool _loading; + private bool _canSearch; + private bool _canReassignParticipant; + private string _selectedAssigneeId = " "; + + private ParticipantPaginationDto _currentDto = new() { Id = "" }; + + private ParticipantsWithPagination.Query Query { get; set; } = new(); + + [CascadingParameter] private Task AuthState { get; set; } = default!; + [CascadingParameter] private UserProfile? UserProfile { get; set; } + + private List ParticipantIdsToReassign { get; set; } = new(); + + protected override async Task OnInitializedAsync() + { + Title = L["Reassign Participant"]; + var state = await AuthState; + _canSearch = (await AuthService.AuthorizeAsync(state.User, SecurityPolicies.CandidateSearch)).Succeeded; + _canReassignParticipant = (await AuthService.AuthorizeAsync(state.User, SecurityPolicies.UserHasAdditionalRoles)).Succeeded; + UserManager = ScopedServices.GetRequiredService>(); + } + + private async Task> ServerReload(GridState state) + { + try + { + _loading = true; + Query.CurrentUser = UserProfile; + Query.OrderBy = state.SortDefinitions.FirstOrDefault()?.SortBy ?? "Id"; + Query.SortDirection = state.SortDefinitions.FirstOrDefault()?.Descending ?? true ? SortDirection.Descending.ToString() : SortDirection.Ascending.ToString(); + Query.PageNumber = state.Page + 1; + Query.PageSize = state.PageSize; + var result = await GetNewMediator().Send(Query).ConfigureAwait(false); + return new GridData { TotalItems = result.TotalItems, Items = result.Items }; + } + finally + { + _loading = false; + } + } + + private async Task OnSearch(string text) + { + if (_loading) + { + return; + } + _selectedItems = new(); + Query.Keyword = text; + await _table.ReloadServerData(); + } + + private async Task OnChangedListView(ParticipantListView listview) + { + Query.ListView = listview; + await _table.ReloadServerData(); + } + + private async Task OnRefresh() + { + ParticipantCacheKey.Refresh(); + _selectedItems = []; + Query.Keyword = string.Empty; + ParticipantIdsToReassign.Clear(); + await _table.ReloadServerData(); + } + + private async Task ReassignSelectedItems() + { + var command = new ReassignParticipants.Command + { + ParticipantIdsToReassign = ParticipantIdsToReassign, + AssigneeId = _selectedAssigneeId, + CurrentUser = UserProfile + }; + + var result = await GetNewMediator().Send(command); + + if (result.Succeeded is false) + { + Snackbar.Add("Error Reassigning Participants", Severity.Error); + return; + } + + Snackbar.Add("Participants reassigned", Severity.Success); + ParticipantIdsToReassign.Clear(); + _selectedAssigneeId = " "; + await _table.ReloadServerData(); + } + + private void OnCheckedChanged(string participantId) + { + if (!ParticipantIdsToReassign.Remove(participantId)) + { + ParticipantIdsToReassign.Add(participantId); + } + } + + private async Task OnChangedListView(string assingeeId) + { + _selectedAssigneeId = assingeeId; + await Task.CompletedTask; + } +} \ No newline at end of file diff --git a/src/Server.UI/Services/Navigation/MenuService.cs b/src/Server.UI/Services/Navigation/MenuService.cs index 36c5dec5..70bbd94c 100644 --- a/src/Server.UI/Services/Navigation/MenuService.cs +++ b/src/Server.UI/Services/Navigation/MenuService.cs @@ -1,5 +1,4 @@ -using System.Drawing; -using Cfo.Cats.Application.SecurityConstants; +using Cfo.Cats.Application.SecurityConstants; using Cfo.Cats.Server.UI.Models.NavigationMenu; namespace Cfo.Cats.Server.UI.Services.Navigation; @@ -33,6 +32,13 @@ public class MenuService : IMenuService Href = "/pages/participants", PageStatus = PageStatus.Completed }, + new() + { + Title = "Reassign Participant", + Href = "/pages/participants/Reassign", + PageStatus = PageStatus.Completed, + Roles = [RoleNames.QAFinance, RoleNames.QAOfficer, RoleNames.QASupportManager, RoleNames.QAManager, RoleNames.SMT, RoleNames.SystemSupport ] + }, } }, new() @@ -41,8 +47,7 @@ public class MenuService : IMenuService Icon = Icons.Material.Filled.Analytics, Href = "/reports", PageStatus = PageStatus.ComingSoon - }, - + }, } }, new MenuSectionModel @@ -86,7 +91,6 @@ public class MenuService : IMenuService Href = "/pages/qa/enrolments/qa2/", Roles = [ RoleNames.QASupportManager, RoleNames.QAManager, RoleNames.SMT, RoleNames.SystemSupport ] } - } } } From 4387b0301abaf30590b59ddcd8b112675db45106 Mon Sep 17 00:00:00 2001 From: Carl Sixsmith Date: Fri, 4 Oct 2024 14:21:46 +0100 Subject: [PATCH 16/27] Use display name --- src/Server.UI/Pages/Participants/ReassignParticipant.razor | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Server.UI/Pages/Participants/ReassignParticipant.razor b/src/Server.UI/Pages/Participants/ReassignParticipant.razor index f5c293b3..96a8ed40 100644 --- a/src/Server.UI/Pages/Participants/ReassignParticipant.razor +++ b/src/Server.UI/Pages/Participants/ReassignParticipant.razor @@ -63,9 +63,9 @@
@L["Please Select Assignee"] - @foreach (var item in UserManager.Users.Where(x => x.TenantId!.StartsWith(UserProfile!.TenantId!))) + @foreach (var item in UserManager.Users.Where(x => x.TenantId!.StartsWith(UserProfile!.TenantId!)).OrderBy((x => x.DisplayName))) { - @item.NormalizedUserName + @item.DisplayName }
From bb454acf8a08df6caf9f288eaa532bf3398591e6 Mon Sep 17 00:00:00 2001 From: Carl Sixsmith Date: Sun, 6 Oct 2024 15:54:49 +0100 Subject: [PATCH 17/27] adjust the reassignment feature to use a dialog, + work with new search restriction --- .../Commands/ReassignParticipants.cs | 22 ++++- .../Constants/ConstantString.cs | 4 +- .../ReassignParticipantDialog.razor | 88 +++++++++++++++++ .../Participants/ReassignParticipant.razor | 99 +++++++------------ 4 files changed, 147 insertions(+), 66 deletions(-) create mode 100644 src/Server.UI/Pages/Participants/Components/ReassignParticipantDialog.razor diff --git a/src/Application/Features/Participants/Commands/ReassignParticipants.cs b/src/Application/Features/Participants/Commands/ReassignParticipants.cs index 1dc82ddf..5ae8a6b1 100644 --- a/src/Application/Features/Participants/Commands/ReassignParticipants.cs +++ b/src/Application/Features/Participants/Commands/ReassignParticipants.cs @@ -9,11 +9,11 @@ public static class ReassignParticipants [RequestAuthorize(Policy = SecurityPolicies.UserHasAdditionalRoles)] public class Command : IRequest> { - public List ParticipantIdsToReassign { get; set; } = new(); + public string[] ParticipantIdsToReassign { get; set; } = []; public UserProfile? CurrentUser { get; set; } - public required string AssigneeId { get; set; } + public string? AssigneeId { get; set; } } public class Handler(IUnitOfWork unitOfWork) : IRequestHandler> @@ -23,7 +23,7 @@ public async Task> Handle(Command request, CancellationToken cancel foreach (var participantId in request.ParticipantIdsToReassign) { var participant = await unitOfWork.DbContext.Participants - .FirstOrDefaultAsync(x => x.Id == participantId); + .FirstOrDefaultAsync(x => x.Id == participantId); if (participant is not null) { @@ -39,6 +39,22 @@ public async Task> Handle(Command request, CancellationToken cancel } } + public class A_ : AbstractValidator + { + public A_() + { + RuleFor(x => x.AssigneeId) + .NotNull() + .MinimumLength(36); + + RuleFor(x => x.ParticipantIdsToReassign) + .NotEmpty(); + + RuleFor(x => x.CurrentUser) + .NotNull(); + } + } + public class A_ParticipantExists : AbstractValidator { private readonly IUnitOfWork _unitOfWork; diff --git a/src/Infrastructure/Constants/ConstantString.cs b/src/Infrastructure/Constants/ConstantString.cs index 4a2e6788..c885e690 100644 --- a/src/Infrastructure/Constants/ConstantString.cs +++ b/src/Infrastructure/Constants/ConstantString.cs @@ -125,6 +125,6 @@ public static string Localize(string key) public static string AddConsent => Localize("Add Consent"); - public static string ReassignParticipant => - Localize("Reassign Participant"); + public static string Reassign => + Localize("Reassign"); } \ No newline at end of file diff --git a/src/Server.UI/Pages/Participants/Components/ReassignParticipantDialog.razor b/src/Server.UI/Pages/Participants/Components/ReassignParticipantDialog.razor new file mode 100644 index 00000000..346a665d --- /dev/null +++ b/src/Server.UI/Pages/Participants/Components/ReassignParticipantDialog.razor @@ -0,0 +1,88 @@ +@using Cfo.Cats.Application.Features.Participants.Commands +@using Cfo.Cats.Domain.Identity +@inherits CatsComponentBase + +@inject IValidationService Validator + +@inject IStringLocalizer L + + + + + + + + Reassign @Model!.ParticipantIdsToReassign.Length @(Model.ParticipantIdsToReassign.Length == 1 ? "participant" : "participants") + + + + @if (_userManager is not null) + { + + @foreach (var item in _userManager.Users.Where(x => x.TenantId!.StartsWith(UserProfile!.TenantId!)).OrderBy((x => x.DisplayName))) + { + @item.DisplayName + } + + } + + + + + + + @ConstantString.Cancel + @ConstantString.Submit + + + +@code{ + + private UserManager? _userManager; + + + private MudForm? _form; + + [EditorRequired] + [Parameter] + public ReassignParticipants.Command? Model { get ; set; } + + [CascadingParameter] private MudDialogInstance MudDialog { get; set; } = default!; + [Parameter] public UserProfile? UserProfile { get; set; } + + + private bool _saving; + + private void Cancel() => MudDialog.Close(); + + protected override void OnInitialized() + { + _userManager = ScopedServices.GetRequiredService>(); + } + + private async Task Submit() + { + try + { + await _form!.Validate().ConfigureAwait(false); + if (_form.IsValid) + { + var result = await GetNewMediator().Send(Model!); + if (result.Succeeded) + { + MudDialog.Close(DialogResult.Ok(true)); + Snackbar.Add("Participants reassigned", Severity.Info); + } + else + { + Snackbar.Add(result.ErrorMessage, Severity.Error); + } + } + } + finally + { + _saving = false; + } + } + +} \ No newline at end of file diff --git a/src/Server.UI/Pages/Participants/ReassignParticipant.razor b/src/Server.UI/Pages/Participants/ReassignParticipant.razor index 96a8ed40..b2bd1d2b 100644 --- a/src/Server.UI/Pages/Participants/ReassignParticipant.razor +++ b/src/Server.UI/Pages/Participants/ReassignParticipant.razor @@ -1,9 +1,7 @@ @page "/pages/participants/Reassign" @using Cfo.Cats.Application.Common.Interfaces.MultiTenant -@using Cfo.Cats.Application.Features.Identity.DTOs -@using Cfo.Cats.Application.Features.Participants.Commands -@using Cfo.Cats.Domain.Common.Enums +@using Cfo.Cats.Application.Features.Participants.Commands @using Cfo.Cats.Domain.Identity @using Cfo.Cats.Server.UI.Pages.Participants.Components @using Cfo.Cats.Application.Features.Participants.Caching @@ -11,14 +9,12 @@ @using Cfo.Cats.Application.Features.Participants.Queries @using Cfo.Cats.Application.Features.Participants.Specifications @using Cfo.Cats.Application.SecurityConstants -@using System.Linq.Expressions - + @inject IStringLocalizer L @inject ITenantService TenantsService @inherits CatsComponentBase -@attribute [Authorize(Policy = SecurityPolicies.AuthorizedUser)] @attribute [Authorize(Policy = SecurityPolicies.UserHasAdditionalRoles)] @Title @@ -45,49 +41,28 @@
- @ConstantString.ReassignParticipant + @ConstantString.Reassign
- @if (_canReassignParticipant) - { -
- -
- Select New Assignee -
- -
- - @L["Please Select Assignee"] - @foreach (var item in UserManager.Users.Where(x => x.TenantId!.StartsWith(UserProfile!.TenantId!)).OrderBy((x => x.DisplayName))) - { - @item.DisplayName - } - -
- -
- - @ConstantString.ReassignParticipant - -
-
- }
+ + @ConstantString.Reassign + + @code { - private UserManager UserManager = null!; - + public string? Title { get; private set; } private int _defaultPageSize = 15; @@ -225,8 +199,7 @@ private MudDataGrid _table = default!; private bool _loading; private bool _canSearch; - private bool _canReassignParticipant; - private string _selectedAssigneeId = " "; + private ParticipantPaginationDto _currentDto = new() { Id = "" }; @@ -242,8 +215,7 @@ Title = L["Reassign Participant"]; var state = await AuthState; _canSearch = (await AuthService.AuthorizeAsync(state.User, SecurityPolicies.CandidateSearch)).Succeeded; - _canReassignParticipant = (await AuthService.AuthorizeAsync(state.User, SecurityPolicies.UserHasAdditionalRoles)).Succeeded; - UserManager = ScopedServices.GetRequiredService>(); + ScopedServices.GetRequiredService>(); } private async Task> ServerReload(GridState state) @@ -256,6 +228,7 @@ Query.SortDirection = state.SortDefinitions.FirstOrDefault()?.Descending ?? true ? SortDirection.Descending.ToString() : SortDirection.Ascending.ToString(); Query.PageNumber = state.Page + 1; Query.PageSize = state.PageSize; + Query.JustMyCases = false; var result = await GetNewMediator().Send(Query).ConfigureAwait(false); return new GridData { TotalItems = result.TotalItems, Items = result.Items }; } @@ -293,25 +266,34 @@ private async Task ReassignSelectedItems() { - var command = new ReassignParticipants.Command + var parameters = new DialogParameters + { + { + x => x.Model, new ReassignParticipants.Command() + { + CurrentUser = UserProfile, + ParticipantIdsToReassign = ParticipantIdsToReassign.ToArray() + } + }, { - ParticipantIdsToReassign = ParticipantIdsToReassign, - AssigneeId = _selectedAssigneeId, - CurrentUser = UserProfile - }; + x => x.UserProfile, + UserProfile + } + }; + + var options = new DialogOptions() { CloseButton = true, MaxWidth = MaxWidth.Medium, FullWidth = true }; + + var dialog = await DialogService.ShowAsync("Reassign participants", parameters, options); - var result = await GetNewMediator().Send(command); + var state = await dialog.Result; - if (result.Succeeded is false) + if (!state!.Canceled) { - Snackbar.Add("Error Reassigning Participants", Severity.Error); - return; + + await _table.ReloadServerData(); } - Snackbar.Add("Participants reassigned", Severity.Success); - ParticipantIdsToReassign.Clear(); - _selectedAssigneeId = " "; - await _table.ReloadServerData(); + } private void OnCheckedChanged(string participantId) @@ -322,9 +304,4 @@ } } - private async Task OnChangedListView(string assingeeId) - { - _selectedAssigneeId = assingeeId; - await Task.CompletedTask; - } } \ No newline at end of file From 6830bb14f7d7227cf6c1de0c5f2a56be23dcbd3b Mon Sep 17 00:00:00 2001 From: Carl Sixsmith Date: Mon, 7 Oct 2024 07:33:47 +0100 Subject: [PATCH 18/27] More reassignment --- .../Shared/Layout/SearchDialog.razor | 6 ++++ .../ReassignParticipantDialog.razor | 8 +++-- .../Participants/ReassignParticipant.razor | 35 ++++++++++++++++++- .../Services/Navigation/MenuService.cs | 4 +-- 4 files changed, 48 insertions(+), 5 deletions(-) diff --git a/src/Server.UI/Components/Shared/Layout/SearchDialog.razor b/src/Server.UI/Components/Shared/Layout/SearchDialog.razor index 37574eda..bc846b9c 100644 --- a/src/Server.UI/Components/Shared/Layout/SearchDialog.razor +++ b/src/Server.UI/Components/Shared/Layout/SearchDialog.razor @@ -81,6 +81,12 @@ if (UserProfile is not null) { + if (UserProfile.AssignedRoles.Any()) + { + pages.Add("Reassign", "/pages/participants/reassign"); + } + + string[] allowed = [RoleNames.QAFinance, RoleNames.SMT, RoleNames.SystemSupport]; if (UserProfile.AssignedRoles.Any(r => allowed.Contains(r))) { diff --git a/src/Server.UI/Pages/Participants/Components/ReassignParticipantDialog.razor b/src/Server.UI/Pages/Participants/Components/ReassignParticipantDialog.razor index 346a665d..ca8b925b 100644 --- a/src/Server.UI/Pages/Participants/Components/ReassignParticipantDialog.razor +++ b/src/Server.UI/Pages/Participants/Components/ReassignParticipantDialog.razor @@ -18,8 +18,12 @@ @if (_userManager is not null) { - - @foreach (var item in _userManager.Users.Where(x => x.TenantId!.StartsWith(UserProfile!.TenantId!)).OrderBy((x => x.DisplayName))) + + @foreach (var item in _userManager.Users + .Where(x => x.TenantId!.StartsWith(UserProfile!.TenantId!)) + .Where(x => x.IsActive) + .Where(x => x.LockoutEnd == null) + .OrderBy((x => x.DisplayName))) { @item.DisplayName } diff --git a/src/Server.UI/Pages/Participants/ReassignParticipant.razor b/src/Server.UI/Pages/Participants/ReassignParticipant.razor index b2bd1d2b..860c50f7 100644 --- a/src/Server.UI/Pages/Participants/ReassignParticipant.razor +++ b/src/Server.UI/Pages/Participants/ReassignParticipant.razor @@ -1,6 +1,8 @@ @page "/pages/participants/Reassign" +@using Cfo.Cats.Application.Common.Interfaces.Locations @using Cfo.Cats.Application.Common.Interfaces.MultiTenant +@using Cfo.Cats.Application.Features.Locations.DTOs @using Cfo.Cats.Application.Features.Participants.Commands @using Cfo.Cats.Domain.Identity @using Cfo.Cats.Server.UI.Pages.Participants.Components @@ -43,9 +45,26 @@
@ConstantString.Reassign + Value="Query.ListView" Dense="false" Label="Enrolment Status">
+
+ + + @foreach (var item in Locations!) + { + + + @item.Name + + } + + +
@@ -190,6 +209,8 @@ @code { + [Inject] + public ILocationService LocationService {get;set;} = default!; public string? Title { get; private set; } private int _defaultPageSize = 15; @@ -200,6 +221,7 @@ private bool _loading; private bool _canSearch; + public LocationDto[] Locations { get; set; } = []; private ParticipantPaginationDto _currentDto = new() { Id = "" }; @@ -215,6 +237,7 @@ Title = L["Reassign Participant"]; var state = await AuthState; _canSearch = (await AuthService.AuthorizeAsync(state.User, SecurityPolicies.CandidateSearch)).Succeeded; + Locations = LocationService.GetVisibleLocations(UserProfile!.TenantId!).OrderByDescending(l => l.LocationType.IsCustody).ThenBy(l => l.Name).ToArray(); ScopedServices.GetRequiredService>(); } @@ -304,4 +327,14 @@ } } + private async Task LocationValuesChanged(IEnumerable selectedValues) + { + Query.Locations = selectedValues.Select(l => l.Id).ToArray(); + await _table.ReloadServerData(); + } + + private string GetMultiSelectionText(List selectedValues) + { + return $"{selectedValues.Count} location{(selectedValues.Count > 1 ? "s have":" has")} been selected"; + } } \ No newline at end of file diff --git a/src/Server.UI/Services/Navigation/MenuService.cs b/src/Server.UI/Services/Navigation/MenuService.cs index 70bbd94c..3559e3d2 100644 --- a/src/Server.UI/Services/Navigation/MenuService.cs +++ b/src/Server.UI/Services/Navigation/MenuService.cs @@ -34,8 +34,8 @@ public class MenuService : IMenuService }, new() { - Title = "Reassign Participant", - Href = "/pages/participants/Reassign", + Title = "Reassign", + Href = "/pages/participants/reassign", PageStatus = PageStatus.Completed, Roles = [RoleNames.QAFinance, RoleNames.QAOfficer, RoleNames.QASupportManager, RoleNames.QAManager, RoleNames.SMT, RoleNames.SystemSupport ] }, From 9d42a148a8c86ebd4335e5d966f903677a3d2098 Mon Sep 17 00:00:00 2001 From: PaulCooperWorkJustice Date: Mon, 7 Oct 2024 11:21:12 +0100 Subject: [PATCH 19/27] Added ability to add 256 characters to comments. Increased mulitline to 4 rows and added a character count --- src/Server.UI/Pages/QA/Enrolments/PQA.razor | 20 +++++++++++------- src/Server.UI/Pages/QA/Enrolments/QA1.razor | 18 +++++++++------- src/Server.UI/Pages/QA/Enrolments/QA2.razor | 23 +++++++++++---------- 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/Server.UI/Pages/QA/Enrolments/PQA.razor b/src/Server.UI/Pages/QA/Enrolments/PQA.razor index 147575a6..ea5b07d5 100644 --- a/src/Server.UI/Pages/QA/Enrolments/PQA.razor +++ b/src/Server.UI/Pages/QA/Enrolments/PQA.razor @@ -77,8 +77,9 @@ - - + + + Characters: @characterCount / 256 Submit @@ -170,11 +171,16 @@ }
- , Severity.Error, options => { - options.RequireInteraction = true; - options.SnackbarVariant = Variant.Text; - }); + , Severity.Error, options => { + options.RequireInteraction = true; + options.SnackbarVariant = Variant.Text; + }); } - + private int characterCount => Command.Message?.Length ?? 0; + + private void UpdateCharacterCount(ChangeEventArgs args) + { + Command.Message = args?.Value?.ToString() ?? string.Empty; + } } \ No newline at end of file diff --git a/src/Server.UI/Pages/QA/Enrolments/QA1.razor b/src/Server.UI/Pages/QA/Enrolments/QA1.razor index c81c6a0c..85ac704b 100644 --- a/src/Server.UI/Pages/QA/Enrolments/QA1.razor +++ b/src/Server.UI/Pages/QA/Enrolments/QA1.razor @@ -33,6 +33,7 @@ margin-bottom: 0.5rem; } + CFO Enrolment Queue First Pass @@ -48,7 +49,6 @@ @if (_participantDto is not null && _participantDto.EnrolmentStatus == EnrolmentStatus.SubmittedToAuthorityStatus) { - @if (_queueEntry!.IsAccepted) { @@ -89,8 +89,9 @@ - - + + + Characters: @characterCount / 256 Submit @@ -108,12 +109,9 @@ } - - @code { - private MudForm? _form; private EnrolmentQueueEntryDto? _queueEntry = null; private ParticipantDto? _participantDto = null; @@ -148,7 +146,6 @@ { Snackbar.Add(result.ErrorMessage, Severity.Info); } - } protected async Task SubmitToQa() @@ -168,7 +165,6 @@ ShowActionFailure("Failed to submit", result); } } - } private void ShowActionFailure(string title, IResult result) @@ -189,4 +185,10 @@ }); } + private int characterCount => Command.Message?.Length ?? 0; + + private void UpdateCharacterCount(ChangeEventArgs args) + { + Command.Message = args?.Value?.ToString() ?? string.Empty; + } } \ No newline at end of file diff --git a/src/Server.UI/Pages/QA/Enrolments/QA2.razor b/src/Server.UI/Pages/QA/Enrolments/QA2.razor index ff951893..7508f580 100644 --- a/src/Server.UI/Pages/QA/Enrolments/QA2.razor +++ b/src/Server.UI/Pages/QA/Enrolments/QA2.razor @@ -90,7 +90,9 @@ - + + Characters: @characterCount / 256 + Submit @@ -107,13 +109,9 @@ } - - - @code { - private MudForm? _form; private EnrolmentQueueEntryDto? _queueEntry = null; private ParticipantDto? _participantDto = null; @@ -126,9 +124,9 @@ private async Task GetQueueItem() { GrabQa2Entry.Command command = new GrabQa2Entry.Command() - { - CurrentUser = UserProfile! - }; + { + CurrentUser = UserProfile! + }; var result = await GetNewMediator().Send(command); if (result.Succeeded) @@ -148,10 +146,8 @@ { Snackbar.Add(result.ErrorMessage, Severity.Info); } - } - protected async Task SubmitToQa() { await _form!.Validate().ConfigureAwait(false); @@ -169,7 +165,6 @@ ShowActionFailure("Failed to submit", result); } } - } private void ShowActionFailure(string title, IResult result) @@ -190,4 +185,10 @@ }); } + private int characterCount => Command.Message?.Length ?? 0; + + private void UpdateCharacterCount(ChangeEventArgs args) + { + Command.Message = args?.Value?.ToString() ?? string.Empty; + } } \ No newline at end of file From 7be7e079b4cc53221758ab72662d04339a5c2763 Mon Sep 17 00:00:00 2001 From: Carl Sixsmith Date: Mon, 7 Oct 2024 12:01:28 +0100 Subject: [PATCH 20/27] Extend to 1000 chars - add validation to request as well - database migration to make fields bigger --- .../Validators/RegularExpressionValidation.cs | 2 + .../Features/Participants/Commands/AddNote.cs | 2 +- .../Commands/SubmitPqaResponse.cs | 3 + .../Commands/SubmitQa1Response.cs | 3 + .../Commands/SubmitQa2Response.cs | 3 + ...tEscalationQueueEntityTypeConfiguration.cs | 6 +- ...nrolmentPqaQueueEntityTypeConfiguration.cs | 5 +- ...nrolmentQa1QueueEntityTypeConfiguration.cs | 5 +- ...nrolmentQa2QueueEntityTypeConfiguration.cs | 5 +- .../ParticipantEntityTypeConfiguration.cs | 3 +- ...241007104940_ExtendNoteLengths.Designer.cs | 2980 +++++++++++++++++ .../20241007104940_ExtendNoteLengths.cs | 128 + .../ApplicationDbContextModelSnapshot.cs | 20 +- .../Components/AddNoteDialog.razor | 10 +- src/Server.UI/Pages/QA/Enrolments/PQA.razor | 7 +- src/Server.UI/Pages/QA/Enrolments/QA1.razor | 5 +- src/Server.UI/Pages/QA/Enrolments/QA2.razor | 5 +- 17 files changed, 3160 insertions(+), 32 deletions(-) create mode 100644 src/Migrators/Migrators.MSSQL/Migrations/20241007104940_ExtendNoteLengths.Designer.cs create mode 100644 src/Migrators/Migrators.MSSQL/Migrations/20241007104940_ExtendNoteLengths.cs diff --git a/src/Application/Common/Validators/RegularExpressionValidation.cs b/src/Application/Common/Validators/RegularExpressionValidation.cs index 717fef71..56d37f8d 100644 --- a/src/Application/Common/Validators/RegularExpressionValidation.cs +++ b/src/Application/Common/Validators/RegularExpressionValidation.cs @@ -16,6 +16,8 @@ public static class ValidationConstants public const string Notes = @"^[A-Za-z0-9 ?.,!""'\/$£&€\r\n\-\(\)@’:;%]*$"; public const string NotesMessage = "{0} must contain only letters, numbers, spaces and common punctuation"; + + public const int NotesLength = 1000; public const string GuidMessage = "{0} must contain a valid Guid"; diff --git a/src/Application/Features/Participants/Commands/AddNote.cs b/src/Application/Features/Participants/Commands/AddNote.cs index 72bf47e0..6ef41609 100644 --- a/src/Application/Features/Participants/Commands/AddNote.cs +++ b/src/Application/Features/Participants/Commands/AddNote.cs @@ -63,7 +63,7 @@ public Validator(IUnitOfWork unitOfWork) RuleFor(c => c.Message) .NotEmpty() - .MaximumLength(255) + .MaximumLength(ValidationConstants.NotesLength) .Matches(ValidationConstants.Notes) .WithMessage(string.Format(ValidationConstants.NotesMessage, "Message")); } diff --git a/src/Application/Features/QualityAssurance/Commands/SubmitPqaResponse.cs b/src/Application/Features/QualityAssurance/Commands/SubmitPqaResponse.cs index b668831a..ea160cc1 100644 --- a/src/Application/Features/QualityAssurance/Commands/SubmitPqaResponse.cs +++ b/src/Application/Features/QualityAssurance/Commands/SubmitPqaResponse.cs @@ -46,6 +46,9 @@ public A_IsValidRequest() .NotNull() .WithMessage("You must accept or return the request"); + RuleFor(x => x.Message) + .MaximumLength(ValidationConstants.NotesLength); + When(x => x.Accept is false, () => { RuleFor(x => x.Message) diff --git a/src/Application/Features/QualityAssurance/Commands/SubmitQa1Response.cs b/src/Application/Features/QualityAssurance/Commands/SubmitQa1Response.cs index f0d8a7cc..5034d5ee 100644 --- a/src/Application/Features/QualityAssurance/Commands/SubmitQa1Response.cs +++ b/src/Application/Features/QualityAssurance/Commands/SubmitQa1Response.cs @@ -45,6 +45,9 @@ public A_IsValidRequest() .NotNull() .WithMessage("You must accept or return the request"); + RuleFor(x => x.Message) + .MaximumLength(ValidationConstants.NotesLength); + When(x => x.Accept is false, () => { RuleFor(x => x.Message) .NotEmpty() diff --git a/src/Application/Features/QualityAssurance/Commands/SubmitQa2Response.cs b/src/Application/Features/QualityAssurance/Commands/SubmitQa2Response.cs index fbc0c259..acd30a1b 100644 --- a/src/Application/Features/QualityAssurance/Commands/SubmitQa2Response.cs +++ b/src/Application/Features/QualityAssurance/Commands/SubmitQa2Response.cs @@ -45,6 +45,9 @@ public A_IsValidRequest() .NotNull() .WithMessage("You must accept or return the request"); + RuleFor(x => x.Message) + .MaximumLength(ValidationConstants.NotesLength); + When(x => x.Accept is false, () => { RuleFor(x => x.Message) .NotEmpty() diff --git a/src/Infrastructure/Persistence/Configurations/Enrolments/EnrolmentEscalationQueueEntityTypeConfiguration.cs b/src/Infrastructure/Persistence/Configurations/Enrolments/EnrolmentEscalationQueueEntityTypeConfiguration.cs index e81c0566..7cedd966 100644 --- a/src/Infrastructure/Persistence/Configurations/Enrolments/EnrolmentEscalationQueueEntityTypeConfiguration.cs +++ b/src/Infrastructure/Persistence/Configurations/Enrolments/EnrolmentEscalationQueueEntityTypeConfiguration.cs @@ -1,4 +1,5 @@ -using Cfo.Cats.Domain.Entities.Participants; +using Cfo.Cats.Application.Common.Validators; +using Cfo.Cats.Domain.Entities.Participants; using Cfo.Cats.Infrastructure.Constants.Database; using Microsoft.EntityFrameworkCore.Metadata.Builders; @@ -26,7 +27,8 @@ public void Configure(EntityTypeBuilder builder) DatabaseConstants.Schemas.Enrolment ); note.HasKey("Id"); - note.Property(x => x.Message).HasMaxLength(256); + note.Property(x => x.Message) + .HasMaxLength(ValidationConstants.NotesLength); note.Property(x => x.CallReference) .HasMaxLength(DatabaseConstants.FieldLengths.CallReference); diff --git a/src/Infrastructure/Persistence/Configurations/Enrolments/EnrolmentPqaQueueEntityTypeConfiguration.cs b/src/Infrastructure/Persistence/Configurations/Enrolments/EnrolmentPqaQueueEntityTypeConfiguration.cs index dce05f04..31bb2664 100644 --- a/src/Infrastructure/Persistence/Configurations/Enrolments/EnrolmentPqaQueueEntityTypeConfiguration.cs +++ b/src/Infrastructure/Persistence/Configurations/Enrolments/EnrolmentPqaQueueEntityTypeConfiguration.cs @@ -1,4 +1,5 @@ -using Cfo.Cats.Domain.Entities.Participants; +using Cfo.Cats.Application.Common.Validators; +using Cfo.Cats.Domain.Entities.Participants; using Cfo.Cats.Infrastructure.Constants.Database; using Microsoft.EntityFrameworkCore.Metadata.Builders; @@ -26,7 +27,7 @@ public void Configure(EntityTypeBuilder builder) DatabaseConstants.Schemas.Enrolment ); note.HasKey("Id"); - note.Property(x => x.Message).HasMaxLength(256); + note.Property(x => x.Message).HasMaxLength(ValidationConstants.NotesLength); note.Property(x => x.CallReference) .HasMaxLength(DatabaseConstants.FieldLengths.CallReference); diff --git a/src/Infrastructure/Persistence/Configurations/Enrolments/EnrolmentQa1QueueEntityTypeConfiguration.cs b/src/Infrastructure/Persistence/Configurations/Enrolments/EnrolmentQa1QueueEntityTypeConfiguration.cs index aaa462c5..8936f393 100644 --- a/src/Infrastructure/Persistence/Configurations/Enrolments/EnrolmentQa1QueueEntityTypeConfiguration.cs +++ b/src/Infrastructure/Persistence/Configurations/Enrolments/EnrolmentQa1QueueEntityTypeConfiguration.cs @@ -1,4 +1,5 @@ -using Cfo.Cats.Domain.Entities.Participants; +using Cfo.Cats.Application.Common.Validators; +using Cfo.Cats.Domain.Entities.Participants; using Cfo.Cats.Infrastructure.Constants.Database; using Microsoft.EntityFrameworkCore.Metadata.Builders; @@ -26,7 +27,7 @@ public void Configure(EntityTypeBuilder builder) DatabaseConstants.Schemas.Enrolment ); note.HasKey("Id"); - note.Property(x => x.Message).HasMaxLength(256); + note.Property(x => x.Message).HasMaxLength(ValidationConstants.NotesLength); note.Property(x => x.CallReference) .HasMaxLength(DatabaseConstants.FieldLengths.CallReference); diff --git a/src/Infrastructure/Persistence/Configurations/Enrolments/EnrolmentQa2QueueEntityTypeConfiguration.cs b/src/Infrastructure/Persistence/Configurations/Enrolments/EnrolmentQa2QueueEntityTypeConfiguration.cs index 414d0a50..ef9f6e9f 100644 --- a/src/Infrastructure/Persistence/Configurations/Enrolments/EnrolmentQa2QueueEntityTypeConfiguration.cs +++ b/src/Infrastructure/Persistence/Configurations/Enrolments/EnrolmentQa2QueueEntityTypeConfiguration.cs @@ -1,4 +1,5 @@ -using Cfo.Cats.Domain.Entities.Participants; +using Cfo.Cats.Application.Common.Validators; +using Cfo.Cats.Domain.Entities.Participants; using Cfo.Cats.Infrastructure.Constants.Database; using Microsoft.EntityFrameworkCore.Metadata.Builders; @@ -26,7 +27,7 @@ public void Configure(EntityTypeBuilder builder) DatabaseConstants.Schemas.Enrolment ); note.HasKey("Id"); - note.Property(x => x.Message).HasMaxLength(256); + note.Property(x => x.Message).HasMaxLength(ValidationConstants.NotesLength); note.Property(x => x.CallReference) .HasMaxLength(DatabaseConstants.FieldLengths.CallReference); diff --git a/src/Infrastructure/Persistence/Configurations/Participants/ParticipantEntityTypeConfiguration.cs b/src/Infrastructure/Persistence/Configurations/Participants/ParticipantEntityTypeConfiguration.cs index ec5722f8..632ff075 100644 --- a/src/Infrastructure/Persistence/Configurations/Participants/ParticipantEntityTypeConfiguration.cs +++ b/src/Infrastructure/Persistence/Configurations/Participants/ParticipantEntityTypeConfiguration.cs @@ -2,6 +2,7 @@ using Cfo.Cats.Infrastructure.Constants.Database; using Microsoft.EntityFrameworkCore.Metadata.Builders; using Cfo.Cats.Domain.Entities.Participants; +using Cfo.Cats.Application.Common.Validators; namespace Cfo.Cats.Infrastructure.Persistence.Configurations.Participants; @@ -178,7 +179,7 @@ public void Configure(EntityTypeBuilder builder) DatabaseConstants.Schemas.Participant ); note.HasKey("Id"); - note.Property(x => x.Message).HasMaxLength(256); + note.Property(x => x.Message).HasMaxLength(ValidationConstants.NotesLength); note.Property(x => x.CallReference) .HasMaxLength(DatabaseConstants.FieldLengths.CallReference); diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20241007104940_ExtendNoteLengths.Designer.cs b/src/Migrators/Migrators.MSSQL/Migrations/20241007104940_ExtendNoteLengths.Designer.cs new file mode 100644 index 00000000..bdc5b88b --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20241007104940_ExtendNoteLengths.Designer.cs @@ -0,0 +1,2980 @@ +// +using System; +using Cfo.Cats.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Cfo.Cats.Migrators.MSSQL.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20241007104940_ExtendNoteLengths")] + partial class ExtendNoteLengths + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Contract", b => + { + b.Property("Id") + .HasMaxLength(12) + .HasColumnType("nvarchar(12)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LotNumber") + .HasColumnType("int"); + + b.Property("_tenantId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("LotNumber") + .IsUnique(); + + b.HasIndex("_tenantId"); + + b.ToTable("Contract", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("_contractId") + .HasMaxLength(12) + .HasColumnType("nvarchar(12)") + .HasColumnName("ContractId"); + + b.Property("_genderProvisionId") + .HasColumnType("int") + .HasColumnName("GenderProvisionId"); + + b.Property("_locationTypeId") + .HasColumnType("int") + .HasColumnName("LocationTypeId"); + + b.Property("_parentLocationId") + .HasColumnType("int") + .HasColumnName("ParentLocationId"); + + b.HasKey("Id"); + + b.HasIndex("_contractId"); + + b.HasIndex("_parentLocationId"); + + b.ToTable("Location", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.LocationMapping", b => + { + b.Property("Code") + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("CodeType") + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("DeliveryRegion") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("_locationId") + .HasColumnType("int") + .HasColumnName("LocationId"); + + b.HasKey("Code", "CodeType"); + + b.HasIndex("_locationId"); + + b.ToTable("LocationMapping", "Dms"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Tenant", b => + { + b.Property("Id") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Tenant", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Assessments.ParticipantAssessment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AssessmentJson") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Completed") + .HasColumnType("datetime2"); + + b.Property("CompletedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("Assessment", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.AuditTrail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AffectedColumns") + .HasColumnType("nvarchar(max)"); + + b.Property("AuditType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateTime") + .HasColumnType("datetime2"); + + b.Property("NewValues") + .HasColumnType("nvarchar(max)"); + + b.Property("OldValues") + .HasColumnType("nvarchar(max)"); + + b.Property("PrimaryKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TableName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AuditTrail", "Audit"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Bios.ParticipantBio", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("BioJson") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Completed") + .HasColumnType("datetime2"); + + b.Property("CompletedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("Bio", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Documents.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("DocumentType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("IsPublic") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("OwnerId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("TenantId") + .HasColumnType("nvarchar(50)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("URL") + .HasColumnType("nvarchar(max)"); + + b.Property("Version") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("LastModifiedBy"); + + b.HasIndex("TenantId"); + + b.ToTable("Document", "Document"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.IdentityAuditTrail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ActionType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("DateTime") + .HasColumnType("datetime2"); + + b.Property("IpAddress") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UserName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("UserName", "DateTime") + .HasDatabaseName("idx_IdentityAudit_UserName_DateTime"); + + b.ToTable("IdentityAuditTrail", "Audit"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Inductions.HubInduction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("InductionDate") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("OwnerId") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("CreatedBy"); + + b.HasIndex("EditorId"); + + b.HasIndex("LocationId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId", "Created"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("ParticipantId", "Created")); + + b.ToTable("HubInduction", "Induction"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Inductions.WingInduction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("InductionDate") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("OwnerId") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("CreatedBy"); + + b.HasIndex("EditorId"); + + b.HasIndex("LocationId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId", "Created"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("ParticipantId", "Created")); + + b.ToTable("WingInduction", "Induction"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.KeyValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Text") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("KeyValue", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.ParticipantAccessAuditTrail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AccessDate") + .HasColumnType("datetime2"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("RequestType") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("AccessAuditTrail", "Audit"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentEscalationQueueEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("IsAccepted") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("EscalationQueue", "Enrolment"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentPqaQueueEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("IsAccepted") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("PqaQueue", "Enrolment"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa1QueueEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("IsAccepted") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("Qa1Queue", "Enrolment"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa2QueueEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("IsAccepted") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("Qa2Queue", "Enrolment"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Participant", b => + { + b.Property("Id") + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("ActiveInFeed") + .HasColumnType("bit"); + + b.Property("AssessmentJustification") + .HasColumnType("nvarchar(max)"); + + b.Property("ConsentStatus") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("DateOfBirth") + .HasColumnType("date"); + + b.Property("EditorId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("EnrolmentLocationJustification") + .HasColumnType("nvarchar(max)"); + + b.Property("EnrolmentStatus") + .HasColumnType("int"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Gender") + .HasMaxLength(6) + .HasColumnType("nvarchar(6)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MiddleName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Nationality") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("OwnerId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ReferralComments") + .HasColumnType("nvarchar(max)"); + + b.Property("ReferralSource") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("RegistrationDetailsJson") + .HasColumnType("nvarchar(max)"); + + b.Property("RiskDue") + .HasColumnType("datetime2"); + + b.Property("_currentLocationId") + .HasColumnType("int") + .HasColumnName("CurrentLocationId"); + + b.Property("_enrolmentLocationId") + .HasColumnType("int") + .HasColumnName("EnrolmentLocationId"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("_currentLocationId"); + + b.HasIndex("_enrolmentLocationId"); + + b.ToTable("Participant", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.ParticipantEnrolmentHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("EnrolmentStatus") + .HasColumnType("int"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("EnrolmentHistory", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.PathwayPlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("PathwayPlan", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Risk", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityRecommendations") + .HasColumnType("nvarchar(max)"); + + b.Property("ActivityRecommendationsReceived") + .HasColumnType("datetime2"); + + b.Property("ActivityRestrictions") + .HasColumnType("nvarchar(max)"); + + b.Property("ActivityRestrictionsReceived") + .HasColumnType("datetime2"); + + b.Property("AdditionalInformation") + .HasColumnType("nvarchar(max)"); + + b.Property("Completed") + .HasColumnType("datetime2"); + + b.Property("CompletedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("IsRelevantToCommunity") + .HasColumnType("bit"); + + b.Property("IsRelevantToCustody") + .HasColumnType("bit"); + + b.Property("IsSubjectToSHPO") + .HasColumnType("int"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LicenseConditions") + .HasColumnType("nvarchar(max)"); + + b.Property("LicenseEnd") + .HasColumnType("datetime2"); + + b.Property("NSDCase") + .HasColumnType("int"); + + b.Property("PSFRestrictions") + .HasColumnType("nvarchar(max)"); + + b.Property("PSFRestrictionsReceived") + .HasColumnType("datetime2"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.Property("ReferredOn") + .HasColumnType("datetime2"); + + b.Property("ReferrerEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("ReferrerName") + .HasColumnType("nvarchar(max)"); + + b.Property("RegistrationDetailsJson") + .HasColumnType("nvarchar(max)"); + + b.Property("ReviewJustification") + .HasColumnType("nvarchar(max)"); + + b.Property("ReviewReason") + .HasColumnType("int"); + + b.Property("RiskToChildrenInCommunity") + .HasColumnType("int"); + + b.Property("RiskToChildrenInCustody") + .HasColumnType("int"); + + b.Property("RiskToKnownAdultInCommunity") + .HasColumnType("int"); + + b.Property("RiskToKnownAdultInCustody") + .HasColumnType("int"); + + b.Property("RiskToOtherPrisonersInCustody") + .HasColumnType("int"); + + b.Property("RiskToPublicInCommunity") + .HasColumnType("int"); + + b.Property("RiskToPublicInCustody") + .HasColumnType("int"); + + b.Property("RiskToSelfInCommunity") + .HasColumnType("int"); + + b.Property("RiskToSelfInCustody") + .HasColumnType("int"); + + b.Property("RiskToStaffInCommunity") + .HasColumnType("int"); + + b.Property("RiskToStaffInCustody") + .HasColumnType("int"); + + b.Property("SpecificRisk") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("Risk", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Timeline", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(36)"); + + b.Property("EventType") + .HasColumnType("int"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Line1") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Line2") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Line3") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ParticipantId"); + + b.ToTable("Timeline", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRole", b => + { + b.Property("Id") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("NormalizedName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RoleRank") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("Role", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Group") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RoleId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("RoleClaim", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUser", b => + { + b.Property("Id") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsLive") + .HasColumnType("bit"); + + b.Property("LastLogin") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("MemorableDate") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MemorablePlace") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("ProfilePictureDataUrl") + .HasColumnType("text"); + + b.Property("ProviderId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RefreshToken") + .HasColumnType("nvarchar(max)"); + + b.Property("RefreshTokenExpiryTime") + .HasColumnType("datetime2"); + + b.Property("RequiresPasswordReset") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("SuperiorId") + .HasColumnType("nvarchar(36)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TenantName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.HasIndex("SuperiorId"); + + b.HasIndex("TenantId"); + + b.ToTable("User", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserClaim", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserRole", b => + { + b.Property("UserId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("RoleId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("UserRole", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserToken", b => + { + b.Property("UserId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("UserToken", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.PasswordHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.ToTable("PasswordHistory", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.UserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("UserLogin", "Identity"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("FriendlyName") + .HasColumnType("nvarchar(max)"); + + b.Property("Xml") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("DataProtectionKeys"); + }); + + modelBuilder.Entity("TenantLocation", b => + { + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("nvarchar(50)"); + + b.HasKey("LocationId", "TenantId"); + + b.HasIndex("TenantId"); + + b.ToTable("TenantLocation", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Contract", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("_tenantId"); + + b.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b1 => + { + b1.Property("ContractId") + .HasColumnType("nvarchar(12)"); + + b1.Property("EndDate") + .HasColumnType("datetime2") + .HasColumnName("LifetimeEnd"); + + b1.Property("StartDate") + .HasColumnType("datetime2") + .HasColumnName("LifetimeStart"); + + b1.HasKey("ContractId"); + + b1.ToTable("Contract", "Configuration"); + + b1.WithOwner() + .HasForeignKey("ContractId"); + }); + + b.Navigation("Lifetime") + .IsRequired(); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Location", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Contract", "Contract") + .WithMany("Locations") + .HasForeignKey("_contractId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "ParentLocation") + .WithMany("ChildLocations") + .HasForeignKey("_parentLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b1 => + { + b1.Property("LocationId") + .HasColumnType("int"); + + b1.Property("EndDate") + .HasColumnType("datetime2") + .HasColumnName("LifetimeEnd"); + + b1.Property("StartDate") + .HasColumnType("datetime2") + .HasColumnName("LifetimeStart"); + + b1.HasKey("LocationId"); + + b1.ToTable("Location", "Configuration"); + + b1.WithOwner() + .HasForeignKey("LocationId"); + }); + + b.Navigation("Contract"); + + b.Navigation("Lifetime") + .IsRequired(); + + b.Navigation("ParentLocation"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.LocationMapping", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "Location") + .WithMany("LocationMappings") + .HasForeignKey("_locationId"); + + b.Navigation("Location"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Tenant", b => + { + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.TenantDomain", "Domains", b1 => + { + b1.Property("TenantId") + .HasColumnType("nvarchar(50)"); + + b1.Property("Domain") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.HasKey("TenantId", "Domain"); + + b1.ToTable("TenantDomain", "Configuration"); + + b1.WithOwner() + .HasForeignKey("TenantId"); + }); + + b.Navigation("Domains"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Assessments.ParticipantAssessment", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", null) + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.PathwayScore", "Scores", b1 => + { + b1.Property("AssessmentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Pathway") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b1.Property("Score") + .HasColumnType("float"); + + b1.HasKey("AssessmentId", "Pathway"); + + b1.ToTable("AssessmentPathwayScore", "Participant"); + + b1.WithOwner() + .HasForeignKey("AssessmentId"); + }); + + b.Navigation("Editor"); + + b.Navigation("Owner"); + + b.Navigation("Scores"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.AuditTrail", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Bios.ParticipantBio", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Documents.Document", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("LastModifiedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Editor"); + + b.Navigation("Owner"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Inductions.HubInduction", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Editor"); + + b.Navigation("Location"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Inductions.WingInduction", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.Entities.Inductions.InductionPhase", "Phases", b1 => + { + b1.Property("WingInductionId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Number") + .HasColumnType("int"); + + b1.Property("CompletedDate") + .HasColumnType("datetime2"); + + b1.Property("StartDate") + .HasColumnType("datetime2"); + + b1.HasKey("WingInductionId", "Number"); + + b1.ToTable("WingInductionPhase", "Induction"); + + b1.WithOwner() + .HasForeignKey("WingInductionId"); + }); + + b.Navigation("Editor"); + + b.Navigation("Location"); + + b.Navigation("Owner"); + + b.Navigation("Phases"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.ParticipantAccessAuditTrail", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentEscalationQueueEntry", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("EnrolmentEscalationQueueEntryId") + .HasColumnType("uniqueidentifier"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("EnrolmentEscalationQueueEntryId"); + + b1.HasIndex("LastModifiedBy"); + + b1.ToTable("EscalationNote", "Enrolment"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.WithOwner() + .HasForeignKey("EnrolmentEscalationQueueEntryId"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Editor"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("Participant"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentPqaQueueEntry", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("EnrolmentPqaQueueEntryId") + .HasColumnType("uniqueidentifier"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("EnrolmentPqaQueueEntryId"); + + b1.HasIndex("LastModifiedBy"); + + b1.ToTable("PqaQueueNote", "Enrolment"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.WithOwner() + .HasForeignKey("EnrolmentPqaQueueEntryId"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Editor"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("Participant"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa1QueueEntry", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("EnrolmentQa1QueueEntryId") + .HasColumnType("uniqueidentifier"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("EnrolmentQa1QueueEntryId"); + + b1.HasIndex("LastModifiedBy"); + + b1.ToTable("Qa1QueueNote", "Enrolment"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.WithOwner() + .HasForeignKey("EnrolmentQa1QueueEntryId"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Editor"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("Participant"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa2QueueEntry", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("EnrolmentQa2QueueEntryId") + .HasColumnType("uniqueidentifier"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("EnrolmentQa2QueueEntryId"); + + b1.HasIndex("LastModifiedBy"); + + b1.ToTable("Qa2QueueNote", "Enrolment"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.WithOwner() + .HasForeignKey("EnrolmentQa2QueueEntryId"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Editor"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("Participant"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Participant", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "CurrentLocation") + .WithMany() + .HasForeignKey("_currentLocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_Participant_Location"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "EnrolmentLocation") + .WithMany() + .HasForeignKey("_enrolmentLocationId") + .HasConstraintName("FK_Participant_EnrolmentLocation"); + + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.Consent", "Consents", b1 => + { + b1.Property("ParticipantId") + .HasColumnType("nvarchar(9)"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("_documentId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DocumentId"); + + b1.HasKey("ParticipantId", "Id"); + + b1.HasIndex("_documentId"); + + b1.ToTable("Consent", "Participant"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + + b1.HasOne("Cfo.Cats.Domain.Entities.Documents.Document", "Document") + .WithMany() + .HasForeignKey("_documentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b2 => + { + b2.Property("ConsentParticipantId") + .HasColumnType("nvarchar(9)"); + + b2.Property("ConsentId") + .HasColumnType("int"); + + b2.Property("EndDate") + .HasColumnType("datetime2") + .HasColumnName("ValidTo"); + + b2.Property("StartDate") + .HasColumnType("datetime2") + .HasColumnName("ValidFrom"); + + b2.HasKey("ConsentParticipantId", "ConsentId"); + + b2.ToTable("Consent", "Participant"); + + b2.WithOwner() + .HasForeignKey("ConsentParticipantId", "ConsentId"); + }); + + b1.Navigation("Document"); + + b1.Navigation("Lifetime") + .IsRequired(); + }); + + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.ExternalIdentifier", "ExternalIdentifiers", b1 => + { + b1.Property("Value") + .HasMaxLength(16) + .HasColumnType("nvarchar(16)"); + + b1.Property("Type") + .HasColumnType("int"); + + b1.Property("ParticipantId") + .HasColumnType("nvarchar(9)"); + + b1.HasKey("Value", "Type", "ParticipantId"); + + b1.HasIndex("ParticipantId"); + + b1.ToTable("ExternalIdentifier", "Participant"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + }); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b1.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("LastModifiedBy"); + + b1.HasIndex("ParticipantId"); + + b1.ToTable("Note", "Participant"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.RightToWork", "RightToWorks", b1 => + { + b1.Property("ParticipantId") + .HasColumnType("nvarchar(9)"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("_documentId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DocumentId"); + + b1.HasKey("ParticipantId", "Id"); + + b1.HasIndex("_documentId"); + + b1.ToTable("RightToWork", "Participant"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + + b1.HasOne("Cfo.Cats.Domain.Entities.Documents.Document", "Document") + .WithMany() + .HasForeignKey("_documentId"); + + b1.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b2 => + { + b2.Property("RightToWorkParticipantId") + .HasColumnType("nvarchar(9)"); + + b2.Property("RightToWorkId") + .HasColumnType("int"); + + b2.Property("EndDate") + .HasColumnType("datetime2") + .HasColumnName("ValidTo"); + + b2.Property("StartDate") + .HasColumnType("datetime2") + .HasColumnName("ValidFrom"); + + b2.HasKey("RightToWorkParticipantId", "RightToWorkId"); + + b2.ToTable("RightToWork", "Participant"); + + b2.WithOwner() + .HasForeignKey("RightToWorkParticipantId", "RightToWorkId"); + }); + + b1.Navigation("Document"); + + b1.Navigation("Lifetime") + .IsRequired(); + }); + + b.OwnsOne("Cfo.Cats.Domain.Entities.Participants.Supervisor", "Supervisor", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b1.Property("Address") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b1.Property("EmailAddress") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b1.Property("MobileNumber") + .HasMaxLength(16) + .HasColumnType("nvarchar(16)"); + + b1.Property("Name") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b1.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b1.Property("TelephoneNumber") + .HasMaxLength(16) + .HasColumnType("nvarchar(16)"); + + b1.HasKey("Id"); + + b1.HasIndex("ParticipantId") + .IsUnique(); + + b1.ToTable("Supervisor", "Participant"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + }); + + b.Navigation("Consents"); + + b.Navigation("CurrentLocation"); + + b.Navigation("Editor"); + + b.Navigation("EnrolmentLocation"); + + b.Navigation("ExternalIdentifiers"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("RightToWorks"); + + b.Navigation("Supervisor"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.PathwayPlan", b => + { + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.Objective", "Objectives", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b1.Property("Completed") + .HasColumnType("datetime2"); + + b1.Property("CompletedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("CompletedStatus") + .HasColumnType("int"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("Index") + .HasColumnType("int"); + + b1.Property("Justification") + .HasColumnType("nvarchar(max)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("PathwayPlanId") + .HasColumnType("uniqueidentifier"); + + b1.HasKey("Id"); + + b1.HasIndex("CompletedBy"); + + b1.HasIndex("PathwayPlanId"); + + b1.ToTable("Objective", "Participant"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CompletedByUser") + .WithMany() + .HasForeignKey("CompletedBy"); + + b1.WithOwner() + .HasForeignKey("PathwayPlanId"); + + b1.OwnsMany("Cfo.Cats.Domain.Entities.Participants.ObjectiveTask", "Tasks", b2 => + { + b2.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b2.Property("Completed") + .HasColumnType("datetime2"); + + b2.Property("CompletedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b2.Property("CompletedStatus") + .HasColumnType("int"); + + b2.Property("Created") + .HasColumnType("datetime2"); + + b2.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b2.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b2.Property("Due") + .HasColumnType("datetime2"); + + b2.Property("Index") + .HasColumnType("int"); + + b2.Property("Justification") + .HasColumnType("nvarchar(max)"); + + b2.Property("LastModified") + .HasColumnType("datetime2"); + + b2.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b2.Property("ObjectiveId") + .HasColumnType("uniqueidentifier"); + + b2.HasKey("Id"); + + b2.HasIndex("CompletedBy"); + + b2.HasIndex("ObjectiveId"); + + b2.ToTable("ObjectiveTask", "Participant"); + + b2.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CompletedByUser") + .WithMany() + .HasForeignKey("CompletedBy"); + + b2.WithOwner() + .HasForeignKey("ObjectiveId"); + + b2.Navigation("CompletedByUser"); + }); + + b1.Navigation("CompletedByUser"); + + b1.Navigation("Tasks"); + }); + + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.PathwayPlanReviewHistory", "ReviewHistories", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("PathwayPlanId") + .HasColumnType("uniqueidentifier"); + + b1.HasKey("Id"); + + b1.HasIndex("PathwayPlanId"); + + b1.ToTable("PathwayPlanReviewHistory", "Participant"); + + b1.WithOwner() + .HasForeignKey("PathwayPlanId"); + }); + + b.Navigation("Objectives"); + + b.Navigation("ReviewHistories"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Risk", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Timeline", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByUser"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRoleClaim", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationRole", "Role") + .WithMany("RoleClaims") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUser", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Superior") + .WithMany() + .HasForeignKey("SuperiorId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("LastModifiedBy"); + + b1.HasIndex("UserId"); + + b1.ToTable("Note", "Identity"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.WithOwner() + .HasForeignKey("UserId"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Notes"); + + b.Navigation("Superior"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserClaim", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserRole", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationRole", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserToken", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") + .WithMany("Tokens") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.UserLogin", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") + .WithMany("Logins") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("TenantLocation", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", null) + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", null) + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Contract", b => + { + b.Navigation("Locations"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Location", b => + { + b.Navigation("ChildLocations"); + + b.Navigation("LocationMappings"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRole", b => + { + b.Navigation("RoleClaims"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUser", b => + { + b.Navigation("Logins"); + + b.Navigation("Tokens"); + + b.Navigation("UserClaims"); + + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20241007104940_ExtendNoteLengths.cs b/src/Migrators/Migrators.MSSQL/Migrations/20241007104940_ExtendNoteLengths.cs new file mode 100644 index 00000000..6daa6c13 --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20241007104940_ExtendNoteLengths.cs @@ -0,0 +1,128 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Cfo.Cats.Migrators.MSSQL.Migrations +{ + /// + public partial class ExtendNoteLengths : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Message", + schema: "Enrolment", + table: "Qa2QueueNote", + type: "nvarchar(1000)", + maxLength: 1000, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(256)", + oldMaxLength: 256); + + migrationBuilder.AlterColumn( + name: "Message", + schema: "Enrolment", + table: "Qa1QueueNote", + type: "nvarchar(1000)", + maxLength: 1000, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(256)", + oldMaxLength: 256); + + migrationBuilder.AlterColumn( + name: "Message", + schema: "Enrolment", + table: "PqaQueueNote", + type: "nvarchar(1000)", + maxLength: 1000, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(256)", + oldMaxLength: 256); + + migrationBuilder.AlterColumn( + name: "Message", + schema: "Participant", + table: "Note", + type: "nvarchar(1000)", + maxLength: 1000, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(256)", + oldMaxLength: 256); + + migrationBuilder.AlterColumn( + name: "Message", + schema: "Enrolment", + table: "EscalationNote", + type: "nvarchar(1000)", + maxLength: 1000, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(256)", + oldMaxLength: 256); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Message", + schema: "Enrolment", + table: "Qa2QueueNote", + type: "nvarchar(256)", + maxLength: 256, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(1000)", + oldMaxLength: 1000); + + migrationBuilder.AlterColumn( + name: "Message", + schema: "Enrolment", + table: "Qa1QueueNote", + type: "nvarchar(256)", + maxLength: 256, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(1000)", + oldMaxLength: 1000); + + migrationBuilder.AlterColumn( + name: "Message", + schema: "Enrolment", + table: "PqaQueueNote", + type: "nvarchar(256)", + maxLength: 256, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(1000)", + oldMaxLength: 1000); + + migrationBuilder.AlterColumn( + name: "Message", + schema: "Participant", + table: "Note", + type: "nvarchar(256)", + maxLength: 256, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(1000)", + oldMaxLength: 1000); + + migrationBuilder.AlterColumn( + name: "Message", + schema: "Enrolment", + table: "EscalationNote", + type: "nvarchar(256)", + maxLength: 256, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(1000)", + oldMaxLength: 1000); + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs b/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs index 5940e776..196c84b0 100644 --- a/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs @@ -1923,8 +1923,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b1.Property("Message") .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); b1.Property("TenantId") .IsRequired() @@ -2020,8 +2020,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b1.Property("Message") .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); b1.Property("TenantId") .IsRequired() @@ -2117,8 +2117,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b1.Property("Message") .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); b1.Property("TenantId") .IsRequired() @@ -2214,8 +2214,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b1.Property("Message") .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); b1.Property("TenantId") .IsRequired() @@ -2404,8 +2404,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b1.Property("Message") .IsRequired() - .HasMaxLength(256) - .HasColumnType("nvarchar(256)"); + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); b1.Property("ParticipantId") .IsRequired() diff --git a/src/Server.UI/Pages/Participants/Components/AddNoteDialog.razor b/src/Server.UI/Pages/Participants/Components/AddNoteDialog.razor index d7d04f3d..2c9f0f03 100644 --- a/src/Server.UI/Pages/Participants/Components/AddNoteDialog.razor +++ b/src/Server.UI/Pages/Participants/Components/AddNoteDialog.razor @@ -1,4 +1,5 @@ -@using Cfo.Cats.Application.Features.Participants.Commands +@using Cfo.Cats.Application.Common.Validators +@using Cfo.Cats.Application.Features.Participants.Commands @inherits CatsComponentBase @inject IValidationService Validator @@ -16,13 +17,12 @@ Required="true" RequiredError="Message is required!" Lines="5" - MaxLength=@maxChars + MaxLength=@ValidationConstants.NotesLength Immediate="true"> - @($"{Model.Message.Length}/{maxChars} characters") + Characters: @Model.Message.Length / @ValidationConstants.NotesLength - @@ -37,7 +37,7 @@ @code { private MudForm? form; - int maxChars = 255; + [CascadingParameter] private MudDialogInstance MudDialog { get; set; } = default!; diff --git a/src/Server.UI/Pages/QA/Enrolments/PQA.razor b/src/Server.UI/Pages/QA/Enrolments/PQA.razor index ea5b07d5..25d9bbdc 100644 --- a/src/Server.UI/Pages/QA/Enrolments/PQA.razor +++ b/src/Server.UI/Pages/QA/Enrolments/PQA.razor @@ -2,6 +2,7 @@ @attribute [Authorize(Policy = SecurityPolicies.Pqa)] +@using Cfo.Cats.Application.Common.Validators @using Cfo.Cats.Application.Features.Participants.DTOs @using Cfo.Cats.Application.Features.Participants.Queries @using Cfo.Cats.Application.Features.QualityAssurance.Commands @@ -78,8 +79,8 @@ - - Characters: @characterCount / 256 + + Characters: @characterCount / 1000 Submit @@ -183,4 +184,4 @@ { Command.Message = args?.Value?.ToString() ?? string.Empty; } -} \ No newline at end of file +} \ No newline at end of file diff --git a/src/Server.UI/Pages/QA/Enrolments/QA1.razor b/src/Server.UI/Pages/QA/Enrolments/QA1.razor index 85ac704b..5aa4e9fd 100644 --- a/src/Server.UI/Pages/QA/Enrolments/QA1.razor +++ b/src/Server.UI/Pages/QA/Enrolments/QA1.razor @@ -1,5 +1,6 @@ @page "/pages/qa/enrolments/qa1/" +@using Cfo.Cats.Application.Common.Validators @using Cfo.Cats.Application.Features.Documents.Queries @using Cfo.Cats.Application.Features.Participants.DTOs @using Cfo.Cats.Application.Features.Participants.Queries @@ -90,8 +91,8 @@ - - Characters: @characterCount / 256 + + Characters: @characterCount / 1000 Submit diff --git a/src/Server.UI/Pages/QA/Enrolments/QA2.razor b/src/Server.UI/Pages/QA/Enrolments/QA2.razor index 7508f580..4ee3341b 100644 --- a/src/Server.UI/Pages/QA/Enrolments/QA2.razor +++ b/src/Server.UI/Pages/QA/Enrolments/QA2.razor @@ -1,5 +1,6 @@ @page "/pages/qa/enrolments/qa2/" +@using Cfo.Cats.Application.Common.Validators @using Cfo.Cats.Application.Features.Documents.Queries @using Cfo.Cats.Application.Features.Participants.DTOs @using Cfo.Cats.Application.Features.Participants.Queries @@ -90,8 +91,8 @@ - - Characters: @characterCount / 256 + + Characters: @characterCount / 1000 From a5e80dfbad00313ef767c6adce03ee4af49e19e3 Mon Sep 17 00:00:00 2001 From: Carl Sixsmith Date: Mon, 7 Oct 2024 14:19:28 +0100 Subject: [PATCH 21/27] CFODEV-767: add a "comment / defer" option that will allow a pqa to keep the case --- .../Commands/SubmitPqaResponse.cs | 41 ++++++++++++++----- .../Commands/SubmitQa1Response.cs | 5 ++- .../Commands/SubmitQa2Response.cs | 5 ++- .../Participants/EnrolmentQueueEntry.cs | 24 +++++------ src/Server.UI/Pages/QA/Enrolments/PQA.razor | 20 ++++++--- 5 files changed, 63 insertions(+), 32 deletions(-) diff --git a/src/Application/Features/QualityAssurance/Commands/SubmitPqaResponse.cs b/src/Application/Features/QualityAssurance/Commands/SubmitPqaResponse.cs index ea160cc1..107d62f8 100644 --- a/src/Application/Features/QualityAssurance/Commands/SubmitPqaResponse.cs +++ b/src/Application/Features/QualityAssurance/Commands/SubmitPqaResponse.cs @@ -11,12 +11,21 @@ public class Command : IRequest { public required Guid QueueEntryId { get; set; } - public bool? Accept { get; set; } + public PqaResponse? Response { get; set; } public string Message { get; set; } = default!; public UserProfile? CurrentUser { get; set; } + + + } + + public enum PqaResponse + { + Accept = 0, + Return = 1, + Comment = 2 } - + public class Handler(IUnitOfWork unitOfWork) : IRequestHandler { public async Task Handle(Command request, CancellationToken cancellationToken) @@ -29,10 +38,22 @@ public async Task Handle(Command request, CancellationToken cancellation { return Result.Failure("Cannot find queue item"); } + + if (string.IsNullOrWhiteSpace(request.Message) == false) + { + entry.AddNote(request.Message); + } + + if (request.Response is PqaResponse.Accept or PqaResponse.Return) + { + bool accepted = request.Response == PqaResponse.Accept; + + entry.Complete(accepted); + EnrolmentStatus transitionTo = accepted ? EnrolmentStatus.SubmittedToAuthorityStatus : EnrolmentStatus.EnrollingStatus; + entry.Participant!.TransitionTo(transitionTo); + } - entry.Complete(request.Accept.GetValueOrDefault(), request.Message); - EnrolmentStatus transitionTo = request.Accept.GetValueOrDefault() ? EnrolmentStatus.SubmittedToAuthorityStatus : EnrolmentStatus.EnrollingStatus; - entry.Participant!.TransitionTo(transitionTo); + return Result.Success(); } @@ -42,19 +63,19 @@ public class A_IsValidRequest : AbstractValidator { public A_IsValidRequest() { - RuleFor(x => x.Accept) + RuleFor(x => x.Response) .NotNull() - .WithMessage("You must accept or return the request"); + .WithMessage("You must select a response"); RuleFor(x => x.Message) .MaximumLength(ValidationConstants.NotesLength); - When(x => x.Accept is false, () => + When(x => x.Response is PqaResponse.Return or PqaResponse.Comment, () => { RuleFor(x => x.Message) .NotEmpty() - .WithMessage("A message is required when returning") - .Matches(ValidationConstants.Notes) + .WithMessage("A message is required for this response.") + .MaximumLength(ValidationConstants.NotesLength) .WithMessage(string.Format(ValidationConstants.NotesMessage, "Message")); }); } diff --git a/src/Application/Features/QualityAssurance/Commands/SubmitQa1Response.cs b/src/Application/Features/QualityAssurance/Commands/SubmitQa1Response.cs index 5034d5ee..1c37cc11 100644 --- a/src/Application/Features/QualityAssurance/Commands/SubmitQa1Response.cs +++ b/src/Application/Features/QualityAssurance/Commands/SubmitQa1Response.cs @@ -30,8 +30,9 @@ public async Task Handle(Command request, CancellationToken cancellation { return Result.Failure("Cannot find queue item"); } - - entry.Complete(request.Accept.GetValueOrDefault(), request.Message); + + entry.AddNote(request.Message) + .Complete(request.Accept.GetValueOrDefault()); return Result.Success(); } diff --git a/src/Application/Features/QualityAssurance/Commands/SubmitQa2Response.cs b/src/Application/Features/QualityAssurance/Commands/SubmitQa2Response.cs index acd30a1b..5f13139b 100644 --- a/src/Application/Features/QualityAssurance/Commands/SubmitQa2Response.cs +++ b/src/Application/Features/QualityAssurance/Commands/SubmitQa2Response.cs @@ -30,9 +30,10 @@ public async Task Handle(Command request, CancellationToken cancellation { return Result.Failure("Cannot find queue item"); } + + entry.AddNote(request.Message) + .Complete(request.Accept.GetValueOrDefault()); - entry.Complete(request.Accept.GetValueOrDefault(), request.Message); - return Result.Success(); } } diff --git a/src/Domain/Entities/Participants/EnrolmentQueueEntry.cs b/src/Domain/Entities/Participants/EnrolmentQueueEntry.cs index 5ea4e178..d471e0ad 100644 --- a/src/Domain/Entities/Participants/EnrolmentQueueEntry.cs +++ b/src/Domain/Entities/Participants/EnrolmentQueueEntry.cs @@ -44,30 +44,28 @@ public EnrolmentQueueEntry AddNote(Note note) return this; } - public EnrolmentQueueEntry Complete(bool accept, string? message = null) + public EnrolmentQueueEntry Complete(bool accept) { - if (!accept && string.IsNullOrWhiteSpace(message)) - { - throw new ArgumentException("Cannot reject a queue entry without a reason"); - } - IsCompleted = true; IsAccepted = accept; - if (string.IsNullOrEmpty(message) == false) + AddDomainEvent(new EnrolmentQueueEntryCompletedDomainEvent(this)); + return this; + } + + public EnrolmentQueueEntry AddNote(string? message) + { + if (string.IsNullOrWhiteSpace(message) == false) { _notes.Add(new Note() { - TenantId = Tenant!.Id, + TenantId = TenantId, Message = message }); } - - AddDomainEvent(new EnrolmentQueueEntryCompletedDomainEvent(this)); - return this; } - - + + public string TenantId { get; set; } = default!; } diff --git a/src/Server.UI/Pages/QA/Enrolments/PQA.razor b/src/Server.UI/Pages/QA/Enrolments/PQA.razor index 25d9bbdc..cc832af3 100644 --- a/src/Server.UI/Pages/QA/Enrolments/PQA.razor +++ b/src/Server.UI/Pages/QA/Enrolments/PQA.razor @@ -69,13 +69,16 @@ { - - + + Accept - + Return + + Comment / Defer + @@ -146,7 +149,14 @@ { var result = await GetNewMediator().Send(Command); - var message = Command.Accept.GetValueOrDefault() ? "Participant submitted to QA" : "Participant returned to Support Worker"; + var message = Command.Response switch + { + SubmitPqaResponse.PqaResponse.Accept => "Participant submitted to QA", + SubmitPqaResponse.PqaResponse.Return => "Participant returned to Support Worker", + _ => "Comment added" + }; + + if (result.Succeeded) { @@ -155,7 +165,7 @@ } else { - ShowActionFailure("Failed to return to support worker", result); + ShowActionFailure("Failed to return to submit", result); } } } From 5882540398d898fc41d64656d901ebe70e6050b2 Mon Sep 17 00:00:00 2001 From: Carl Sixsmith Date: Tue, 8 Oct 2024 12:04:28 +0100 Subject: [PATCH 22/27] CFODEV-771 PQA can now escalate. --- .../Commands/SubmitEscalationResponse.cs | 143 + .../Commands/SubmitPqaResponse.cs | 34 +- .../Commands/SubmitQa1Response.cs | 13 +- .../Commands/SubmitQa2Response.cs | 41 +- .../DTOs/EnrolmentQueueEntryDto.cs | 20 +- ... => CreateNoteForPqaReturnEventHandler.cs} | 14 +- ...CreateQa2QueueEventAfterQa1EventHandler.cs | 15 + ...ntQueueEntryCompletedDomainEventHandler.cs | 34 - .../EventHandlers/Qa2EscalatedEventHandler.cs | 14 + ...ntAfterEscalationSubmissionEventHandler.cs | 26 + ...rticipantAfterPqaSubmissionEventHandler.cs | 25 + ...rticipantAfterQa2SubmissionEventHandler.cs | 26 + ...mentQaEscalationQueueEntrySpecification.cs | 15 + .../Queries/GetEscalationEntryById.cs | 46 + .../Queries/QaEscalationWithPaginiation.cs | 97 + .../SecurityConstants/SecurityPolicies.cs | 2 + .../EnrolmentEscalationQueueEntry.cs | 20 +- .../Participants/EnrolmentPqaQueueEntry.cs | 27 +- .../Participants/EnrolmentQa1QueueEntry.cs | 22 +- .../Participants/EnrolmentQa2QueueEntry.cs | 34 +- .../Participants/EnrolmentQueueEntry.cs | 26 +- ...rlomenentQueueEntryCompletedDomainEvent.cs | 9 - ...mentEscalationEntryCompletedDomainEvent.cs | 8 + .../EnrolmentPqaEntryCompletedDomainEvent.cs | 9 + .../EnrolmentQa1EntryCompletedDomainEvent.cs | 8 + .../EnrolmentQa2EntryCompletedDomainEvent.cs | 8 + .../EnrolmentQa2EntryEscalatedDomainEvent.cs | 9 + src/Infrastructure/DependencyInjection.cs | 6 + ...241008091311_QA_EscalationFlag.Designer.cs | 2983 +++++++++++++++++ .../20241008091311_QA_EscalationFlag.cs | 31 + .../ApplicationDbContextModelSnapshot.cs | 3 + .../Components/EscalationList.razor | 194 ++ .../QA/Enrolments/Components/QA1List.razor | 13 +- .../QA/Enrolments/Components/QA2List.razor | 6 +- .../Pages/QA/Enrolments/Escalation.razor | 191 ++ src/Server.UI/Pages/QA/Enrolments/PQA.razor | 55 +- .../Pages/QA/Enrolments/PqaList.razor | 7 +- src/Server.UI/Pages/QA/Enrolments/QA2.razor | 9 +- .../Pages/QA/Enrolments/QAServiceDesk.razor | 19 + 39 files changed, 4099 insertions(+), 163 deletions(-) create mode 100644 src/Application/Features/QualityAssurance/Commands/SubmitEscalationResponse.cs rename src/Application/Features/QualityAssurance/EventHandlers/{ManagePqaNotesForSubmissionsEventHandler.cs => CreateNoteForPqaReturnEventHandler.cs} (56%) create mode 100644 src/Application/Features/QualityAssurance/EventHandlers/CreateQa2QueueEventAfterQa1EventHandler.cs delete mode 100644 src/Application/Features/QualityAssurance/EventHandlers/EnrolmentQueueEntryCompletedDomainEventHandler.cs create mode 100644 src/Application/Features/QualityAssurance/EventHandlers/Qa2EscalatedEventHandler.cs create mode 100644 src/Application/Features/QualityAssurance/EventHandlers/TransitionParticipantAfterEscalationSubmissionEventHandler.cs create mode 100644 src/Application/Features/QualityAssurance/EventHandlers/TransitionParticipantAfterPqaSubmissionEventHandler.cs create mode 100644 src/Application/Features/QualityAssurance/EventHandlers/TransitionParticipantAfterQa2SubmissionEventHandler.cs create mode 100644 src/Application/Features/QualityAssurance/Queries/EnrolmentQaEscalationQueueEntrySpecification.cs create mode 100644 src/Application/Features/QualityAssurance/Queries/GetEscalationEntryById.cs create mode 100644 src/Application/Features/QualityAssurance/Queries/QaEscalationWithPaginiation.cs delete mode 100644 src/Domain/Events/EnrlomenentQueueEntryCompletedDomainEvent.cs create mode 100644 src/Domain/Events/QA/Enrolments/EnrolmentEscalationEntryCompletedDomainEvent.cs create mode 100644 src/Domain/Events/QA/Enrolments/EnrolmentPqaEntryCompletedDomainEvent.cs create mode 100644 src/Domain/Events/QA/Enrolments/EnrolmentQa1EntryCompletedDomainEvent.cs create mode 100644 src/Domain/Events/QA/Enrolments/EnrolmentQa2EntryCompletedDomainEvent.cs create mode 100644 src/Domain/Events/QA/Enrolments/EnrolmentQa2EntryEscalatedDomainEvent.cs create mode 100644 src/Migrators/Migrators.MSSQL/Migrations/20241008091311_QA_EscalationFlag.Designer.cs create mode 100644 src/Migrators/Migrators.MSSQL/Migrations/20241008091311_QA_EscalationFlag.cs create mode 100644 src/Server.UI/Pages/QA/Enrolments/Components/EscalationList.razor create mode 100644 src/Server.UI/Pages/QA/Enrolments/Escalation.razor diff --git a/src/Application/Features/QualityAssurance/Commands/SubmitEscalationResponse.cs b/src/Application/Features/QualityAssurance/Commands/SubmitEscalationResponse.cs new file mode 100644 index 00000000..e831fe35 --- /dev/null +++ b/src/Application/Features/QualityAssurance/Commands/SubmitEscalationResponse.cs @@ -0,0 +1,143 @@ +using Cfo.Cats.Application.Common.Security; +using Cfo.Cats.Application.Common.Validators; +using Cfo.Cats.Application.SecurityConstants; + +namespace Cfo.Cats.Application.Features.QualityAssurance.Commands; + +public static class SubmitEscalationResponse +{ + [RequestAuthorize(Policy = SecurityPolicies.SeniorInternal)] + public class Command : IRequest + { + public required Guid QueueEntryId { get; set; } + + public EscalationResponse? Response { get; set; } + + public string Message { get; set; } = default!; + public UserProfile? CurrentUser { get; set; } + + } + + public enum EscalationResponse + { + Accept = 0, + Return = 1, + Comment = 2 + } + + public class Handler(IUnitOfWork unitOfWork) : IRequestHandler + { + public async Task Handle(Command request, CancellationToken cancellationToken) + { + var entry = await unitOfWork.DbContext.EnrolmentEscalationQueue + .Include(pqa => pqa.Participant) + .FirstOrDefaultAsync(x => x.Id == request.QueueEntryId, cancellationToken: cancellationToken); + + if (entry == null) + { + return Result.Failure("Cannot find queue item"); + } + + entry.AddNote(request.Message); + + switch (request.Response) + { + case EscalationResponse.Accept: + entry.Accept(); + break; + case EscalationResponse.Return: + entry.Return(); + break; + case EscalationResponse.Comment: + break; + default: + throw new ArgumentOutOfRangeException(); + } + + return Result.Success(); + } + } + + public class A_IsValidRequest : AbstractValidator + { + public A_IsValidRequest() + { + RuleFor(x => x.Response) + .NotNull() + .WithMessage("You must select a response"); + + RuleFor(x => x.Message) + .MaximumLength(ValidationConstants.NotesLength); + + When(x => x.Response is EscalationResponse.Return or EscalationResponse.Comment, () => + { + RuleFor(x => x.Message) + .NotEmpty() + .WithMessage("A message is required for this response.") + .MaximumLength(ValidationConstants.NotesLength) + .WithMessage(string.Format(ValidationConstants.NotesMessage, "Message")); + }); + } + } + + public class B_EntryMustExist : AbstractValidator + { + private readonly IUnitOfWork _unitOfWork; + + public B_EntryMustExist(IUnitOfWork unitOfWork) + { + _unitOfWork = unitOfWork; + + RuleFor(c => c.QueueEntryId) + .MustAsync(MustExist) + .WithMessage("Queue item does not exist"); + } + private async Task MustExist(Guid identifier, CancellationToken cancellationToken) + => await _unitOfWork.DbContext.EnrolmentEscalationQueue.AnyAsync(e => e.Id == identifier, cancellationToken); + } + + public class C_ShouldNotBeComplete : AbstractValidator + { + private readonly IUnitOfWork _unitOfWork; + + public C_ShouldNotBeComplete(IUnitOfWork unitOfWork) + { + _unitOfWork = unitOfWork; + + RuleFor(c => c.QueueEntryId) + .MustAsync(MustBeOpen) + .WithMessage("Queue item is already completed."); + } + + private async Task MustBeOpen(Guid id, CancellationToken cancellationToken) + { + var entry = await _unitOfWork.DbContext.EnrolmentEscalationQueue.Include(c => c.Participant) + .FirstOrDefaultAsync(a => a.Id == id, cancellationToken: cancellationToken); + + return entry is { IsCompleted: false }; + } + } + + public class D_ShouldNotBeAtPqaStatus : AbstractValidator + { + private readonly IUnitOfWork _unitOfWork; + + public D_ShouldNotBeAtPqaStatus(IUnitOfWork unitOfWork) + { + _unitOfWork = unitOfWork; + + RuleFor(c => c.QueueEntryId) + .MustAsync(MustBeAtSubmittedToAuthority) + .WithMessage("Queue item is not at Submitted to Authority stage"); + } + + private async Task MustBeAtSubmittedToAuthority(Guid id, CancellationToken cancellationToken) + { + var entry = await _unitOfWork.DbContext.EnrolmentEscalationQueue.Include(c => c.Participant) + .FirstOrDefaultAsync(a => a.Id == id, cancellationToken: cancellationToken); + + return entry != null && entry.Participant!.EnrolmentStatus == EnrolmentStatus.SubmittedToAuthorityStatus; + } + } + +} \ No newline at end of file diff --git a/src/Application/Features/QualityAssurance/Commands/SubmitPqaResponse.cs b/src/Application/Features/QualityAssurance/Commands/SubmitPqaResponse.cs index 107d62f8..4a10dabc 100644 --- a/src/Application/Features/QualityAssurance/Commands/SubmitPqaResponse.cs +++ b/src/Application/Features/QualityAssurance/Commands/SubmitPqaResponse.cs @@ -16,7 +16,6 @@ public class Command : IRequest public string Message { get; set; } = default!; public UserProfile? CurrentUser { get; set; } - } public enum PqaResponse @@ -39,22 +38,22 @@ public async Task Handle(Command request, CancellationToken cancellation return Result.Failure("Cannot find queue item"); } - if (string.IsNullOrWhiteSpace(request.Message) == false) - { - entry.AddNote(request.Message); - } + entry.AddNote(request.Message); - if (request.Response is PqaResponse.Accept or PqaResponse.Return) + switch (request.Response) { - bool accepted = request.Response == PqaResponse.Accept; - - entry.Complete(accepted); - EnrolmentStatus transitionTo = accepted ? EnrolmentStatus.SubmittedToAuthorityStatus : EnrolmentStatus.EnrollingStatus; - entry.Participant!.TransitionTo(transitionTo); + case PqaResponse.Accept: + entry.Accept(); + break; + case PqaResponse.Return: + entry.Return(); + break; + case PqaResponse.Comment: + break; + default: + throw new ArgumentOutOfRangeException(); } - - return Result.Success(); } } @@ -83,7 +82,8 @@ public A_IsValidRequest() public class B_EntryMustExist : AbstractValidator { - private IUnitOfWork _unitOfWork; + private readonly IUnitOfWork _unitOfWork; + public B_EntryMustExist(IUnitOfWork unitOfWork) { _unitOfWork = unitOfWork; @@ -98,7 +98,7 @@ private async Task MustExist(Guid identifier, CancellationToken cancellati public class C_ShouldNotBeComplete : AbstractValidator { - private IUnitOfWork _unitOfWork; + private readonly IUnitOfWork _unitOfWork; public C_ShouldNotBeComplete(IUnitOfWork unitOfWork) { @@ -120,7 +120,7 @@ private async Task MustBeOpen(Guid id, CancellationToken cancellationToken public class D_ShouldNotBeAtPqaStatus : AbstractValidator { - private IUnitOfWork _unitOfWork; + private readonly IUnitOfWork _unitOfWork; public D_ShouldNotBeAtPqaStatus(IUnitOfWork unitOfWork) { @@ -141,7 +141,7 @@ private async Task MustBeAtPqA(Guid id, CancellationToken cancellationToke } public class E_OwnerShouldNotBeApprover : AbstractValidator { - private IUnitOfWork _unitOfWork; + private readonly IUnitOfWork _unitOfWork; public E_OwnerShouldNotBeApprover(IUnitOfWork unitOfWork) { _unitOfWork = unitOfWork; diff --git a/src/Application/Features/QualityAssurance/Commands/SubmitQa1Response.cs b/src/Application/Features/QualityAssurance/Commands/SubmitQa1Response.cs index 1c37cc11..97ca17e2 100644 --- a/src/Application/Features/QualityAssurance/Commands/SubmitQa1Response.cs +++ b/src/Application/Features/QualityAssurance/Commands/SubmitQa1Response.cs @@ -31,8 +31,17 @@ public async Task Handle(Command request, CancellationToken cancellation return Result.Failure("Cannot find queue item"); } - entry.AddNote(request.Message) - .Complete(request.Accept.GetValueOrDefault()); + entry.AddNote(request.Message); + + if (request.Accept.GetValueOrDefault()) + { + entry.Accept(); + } + else + { + entry.Return(); + } + return Result.Success(); } diff --git a/src/Application/Features/QualityAssurance/Commands/SubmitQa2Response.cs b/src/Application/Features/QualityAssurance/Commands/SubmitQa2Response.cs index 5f13139b..c0a170a7 100644 --- a/src/Application/Features/QualityAssurance/Commands/SubmitQa2Response.cs +++ b/src/Application/Features/QualityAssurance/Commands/SubmitQa2Response.cs @@ -2,6 +2,7 @@ using Cfo.Cats.Application.Common.Validators; using Cfo.Cats.Application.SecurityConstants; using Cfo.Cats.Domain.Entities.Participants; +using static Cfo.Cats.Application.Features.QualityAssurance.Commands.SubmitPqaResponse; namespace Cfo.Cats.Application.Features.QualityAssurance.Commands; @@ -12,12 +13,19 @@ public class Command : IRequest { public required Guid QueueEntryId { get; set; } - public bool? Accept { get; set; } + public Qa2Response? Response { get; set; } public string Message { get; set; } = default!; public UserProfile? CurrentUser { get; set; } } - + + public enum Qa2Response + { + Accept = 0, + Return = 1, + Escalate = 2 + } + public class Handler(IUnitOfWork unitOfWork) : IRequestHandler { public async Task Handle(Command request, CancellationToken cancellationToken) @@ -31,9 +39,24 @@ public async Task Handle(Command request, CancellationToken cancellation return Result.Failure("Cannot find queue item"); } - entry.AddNote(request.Message) - .Complete(request.Accept.GetValueOrDefault()); - + entry.AddNote(request.Message); + + + switch (request.Response) + { + case Qa2Response.Accept: + entry.Accept(); + break; + case Qa2Response.Return: + entry.Return(); + break; + case Qa2Response.Escalate: + entry.Escalate(); + break; + default: + throw new ArgumentOutOfRangeException(); + } + return Result.Success(); } } @@ -42,17 +65,17 @@ public class A_IsValidRequest : AbstractValidator { public A_IsValidRequest() { - RuleFor(x => x.Accept) + RuleFor(x => x.Response) .NotNull() - .WithMessage("You must accept or return the request"); + .WithMessage("You must select a response"); RuleFor(x => x.Message) .MaximumLength(ValidationConstants.NotesLength); - When(x => x.Accept is false, () => { + When(x => x.Response is Qa2Response.Return or Qa2Response.Escalate, () => { RuleFor(x => x.Message) .NotEmpty() - .WithMessage("A message is required when returning") + .WithMessage("A message is required for this response") .Matches(ValidationConstants.Notes) .WithMessage(string.Format(ValidationConstants.NotesMessage, "Message")); }); diff --git a/src/Application/Features/QualityAssurance/DTOs/EnrolmentQueueEntryDto.cs b/src/Application/Features/QualityAssurance/DTOs/EnrolmentQueueEntryDto.cs index 8878d0c3..b71130fb 100644 --- a/src/Application/Features/QualityAssurance/DTOs/EnrolmentQueueEntryDto.cs +++ b/src/Application/Features/QualityAssurance/DTOs/EnrolmentQueueEntryDto.cs @@ -79,7 +79,25 @@ public Mapping() )) .ForMember(target => target.Notes, options => options.MapFrom(source => source.Notes)) .ForMember(target => target.AssignedTo, options => options.MapFrom(source => source.Owner!.DisplayName)); - + + CreateMap() + .ForMember(target => target.ParticipantId, + options => options.MapFrom(source => source.ParticipantId)) + .ForMember(target => target.Created, + options => options.MapFrom(source => source.Created)) + .ForMember(target => target.TenantId, + options => options.MapFrom(source => source.TenantId)) + .ForMember(target => target.TenantName, + options => options.MapFrom(source => source.Tenant!.Name)) + .ForMember(target => target.ParticipantName, options => { + options.MapFrom(target => target.Participant!.FirstName + " " + target.Participant.LastName); + }) + .ForMember(target => target.SupportWorker, options => options.MapFrom( + source => source.Participant!.Owner!.DisplayName + )) + .ForMember(target => target.Notes, options => options.MapFrom(source => source.Notes)) + .ForMember(target => target.AssignedTo, options => options.MapFrom(source => source.Owner!.DisplayName)); + } } diff --git a/src/Application/Features/QualityAssurance/EventHandlers/ManagePqaNotesForSubmissionsEventHandler.cs b/src/Application/Features/QualityAssurance/EventHandlers/CreateNoteForPqaReturnEventHandler.cs similarity index 56% rename from src/Application/Features/QualityAssurance/EventHandlers/ManagePqaNotesForSubmissionsEventHandler.cs rename to src/Application/Features/QualityAssurance/EventHandlers/CreateNoteForPqaReturnEventHandler.cs index a474d76a..c2ec9157 100644 --- a/src/Application/Features/QualityAssurance/EventHandlers/ManagePqaNotesForSubmissionsEventHandler.cs +++ b/src/Application/Features/QualityAssurance/EventHandlers/CreateNoteForPqaReturnEventHandler.cs @@ -1,25 +1,25 @@ using Cfo.Cats.Domain.Entities.Participants; -using Cfo.Cats.Domain.Events; +using Cfo.Cats.Domain.Events.QA.Enrolments; using Cfo.Cats.Domain.ValueObjects; namespace Cfo.Cats.Application.Features.QualityAssurance.EventHandlers; -public class ManagePqaNotesForSubmissionsEventHandler : INotificationHandler +public class CreateNoteForPqaReturnEventHandler : INotificationHandler { - public Task Handle(EnrolmentQueueEntryCompletedDomainEvent notification, CancellationToken cancellationToken) + public Task Handle(EnrolmentPqaEntryCompletedDomainEvent notification, CancellationToken cancellationToken) { - if (notification.Entry is EnrolmentPqaQueueEntry { IsAccepted: false, Notes.Count: > 0 } returned) + if (notification.Entry is { IsAccepted: false, Notes.Count: > 0 } returned) { // if the PQA has returned the submission, add the notes to the generic notes for now // so the caseworker has visibility var n = returned.Notes.First(); - returned.Participant!.AddNote(new Note() + returned.Participant!.AddNote(new Note { Message = n.Message, TenantId = notification.Entry!.Participant!.Owner!.TenantId! }); } - + return Task.CompletedTask; } -} +} \ No newline at end of file diff --git a/src/Application/Features/QualityAssurance/EventHandlers/CreateQa2QueueEventAfterQa1EventHandler.cs b/src/Application/Features/QualityAssurance/EventHandlers/CreateQa2QueueEventAfterQa1EventHandler.cs new file mode 100644 index 00000000..0796f598 --- /dev/null +++ b/src/Application/Features/QualityAssurance/EventHandlers/CreateQa2QueueEventAfterQa1EventHandler.cs @@ -0,0 +1,15 @@ +using Cfo.Cats.Domain.Entities.Participants; +using Cfo.Cats.Domain.Events.QA.Enrolments; + +namespace Cfo.Cats.Application.Features.QualityAssurance.EventHandlers; + +public class CreateQa2QueueEventAfterQa1EventHandler(IUnitOfWork unitOfWork) + : INotificationHandler +{ + public async Task Handle(EnrolmentQa1EntryCompletedDomainEvent notification, CancellationToken cancellationToken) + { + var entry = EnrolmentQa2QueueEntry.Create(notification.Entry.ParticipantId); + entry.TenantId = notification.Entry!.Participant!.Owner!.TenantId!; + await unitOfWork.DbContext.EnrolmentQa2Queue.AddAsync(entry, cancellationToken); + } +} \ No newline at end of file diff --git a/src/Application/Features/QualityAssurance/EventHandlers/EnrolmentQueueEntryCompletedDomainEventHandler.cs b/src/Application/Features/QualityAssurance/EventHandlers/EnrolmentQueueEntryCompletedDomainEventHandler.cs deleted file mode 100644 index 5d3a5b61..00000000 --- a/src/Application/Features/QualityAssurance/EventHandlers/EnrolmentQueueEntryCompletedDomainEventHandler.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Cfo.Cats.Domain.Entities.Participants; -using Cfo.Cats.Domain.Events; - -namespace Cfo.Cats.Application.Features.QualityAssurance.EventHandlers; - -public class EnrolmentQueueEntryCompletedDomainEventHandler(IUnitOfWork unitOfWork) : INotificationHandler -{ - public async Task Handle(EnrolmentQueueEntryCompletedDomainEvent notification, CancellationToken cancellationToken) - { - if (notification.Entry is EnrolmentQa1QueueEntry) - { - var entry = EnrolmentQa2QueueEntry.Create(notification.Entry.ParticipantId); - entry.TenantId = notification.Entry!.Participant!.Owner!.TenantId!; - await unitOfWork.DbContext.EnrolmentQa2Queue.AddAsync(entry, cancellationToken); - } - - if (notification.Entry is EnrolmentQa2QueueEntry) - { - if (notification.Entry.IsAccepted) - { - notification.Entry.Participant!.TransitionTo(EnrolmentStatus.ApprovedStatus) - .ApproveConsent(); - } - else - { - notification.Entry.Participant!.TransitionTo(EnrolmentStatus.SubmittedToProviderStatus); - } - } - - - - - } -} \ No newline at end of file diff --git a/src/Application/Features/QualityAssurance/EventHandlers/Qa2EscalatedEventHandler.cs b/src/Application/Features/QualityAssurance/EventHandlers/Qa2EscalatedEventHandler.cs new file mode 100644 index 00000000..cfc835ab --- /dev/null +++ b/src/Application/Features/QualityAssurance/EventHandlers/Qa2EscalatedEventHandler.cs @@ -0,0 +1,14 @@ +using Cfo.Cats.Domain.Entities.Participants; +using Cfo.Cats.Domain.Events.QA.Enrolments; + +namespace Cfo.Cats.Application.Features.QualityAssurance.EventHandlers; + +internal class Qa2EscalatedEventHandler(IUnitOfWork unitOfWork) : INotificationHandler +{ + public async Task Handle(EnrolmentQa2EntryEscalatedDomainEvent notification, CancellationToken cancellationToken) + { + var entry = EnrolmentEscalationQueueEntry.Create(notification.Entry.ParticipantId); + entry.TenantId = notification.Entry!.Participant!.Owner!.TenantId!; + await unitOfWork.DbContext.EnrolmentEscalationQueue.AddAsync(entry, cancellationToken); + } +} \ No newline at end of file diff --git a/src/Application/Features/QualityAssurance/EventHandlers/TransitionParticipantAfterEscalationSubmissionEventHandler.cs b/src/Application/Features/QualityAssurance/EventHandlers/TransitionParticipantAfterEscalationSubmissionEventHandler.cs new file mode 100644 index 00000000..cf43e71c --- /dev/null +++ b/src/Application/Features/QualityAssurance/EventHandlers/TransitionParticipantAfterEscalationSubmissionEventHandler.cs @@ -0,0 +1,26 @@ +using Cfo.Cats.Domain.Events.QA.Enrolments; + +namespace Cfo.Cats.Application.Features.QualityAssurance.EventHandlers; + +public class TransitionParticipantAfterEscalationSubmissionEventHandler + : INotificationHandler +{ + public Task Handle(EnrolmentEscalationEntryCompletedDomainEvent notification, CancellationToken cancellationToken) + { + if (notification.Entry.IsAccepted) + { + notification.Entry + .Participant! + .TransitionTo(EnrolmentStatus.ApprovedStatus) + .ApproveConsent(); + } + else + { + notification.Entry + .Participant! + .TransitionTo(EnrolmentStatus.SubmittedToProviderStatus); + } + + return Task.CompletedTask; + } +} \ No newline at end of file diff --git a/src/Application/Features/QualityAssurance/EventHandlers/TransitionParticipantAfterPqaSubmissionEventHandler.cs b/src/Application/Features/QualityAssurance/EventHandlers/TransitionParticipantAfterPqaSubmissionEventHandler.cs new file mode 100644 index 00000000..79467f40 --- /dev/null +++ b/src/Application/Features/QualityAssurance/EventHandlers/TransitionParticipantAfterPqaSubmissionEventHandler.cs @@ -0,0 +1,25 @@ +using Cfo.Cats.Domain.Events.QA.Enrolments; + +namespace Cfo.Cats.Application.Features.QualityAssurance.EventHandlers; + +public class TransitionParticipantAfterPqaSubmissionEventHandler + : INotificationHandler +{ + public Task Handle(EnrolmentPqaEntryCompletedDomainEvent notification, CancellationToken cancellationToken) + { + if (notification.Entry.IsAccepted) + { + notification.Entry + .Participant! + .TransitionTo(EnrolmentStatus.SubmittedToAuthorityStatus); + } + else + { + notification.Entry + .Participant! + .TransitionTo(EnrolmentStatus.EnrollingStatus); + } + + return Task.CompletedTask; + } +} \ No newline at end of file diff --git a/src/Application/Features/QualityAssurance/EventHandlers/TransitionParticipantAfterQa2SubmissionEventHandler.cs b/src/Application/Features/QualityAssurance/EventHandlers/TransitionParticipantAfterQa2SubmissionEventHandler.cs new file mode 100644 index 00000000..4f1e596c --- /dev/null +++ b/src/Application/Features/QualityAssurance/EventHandlers/TransitionParticipantAfterQa2SubmissionEventHandler.cs @@ -0,0 +1,26 @@ +using Cfo.Cats.Domain.Events.QA.Enrolments; + +namespace Cfo.Cats.Application.Features.QualityAssurance.EventHandlers; + +public class TransitionParticipantAfterQa2SubmissionEventHandler + : INotificationHandler +{ + public Task Handle(EnrolmentQa2EntryCompletedDomainEvent notification, CancellationToken cancellationToken) + { + if (notification.Entry.IsAccepted) + { + notification.Entry + .Participant! + .TransitionTo(EnrolmentStatus.ApprovedStatus) + .ApproveConsent(); + } + else + { + notification.Entry + .Participant! + .TransitionTo(EnrolmentStatus.SubmittedToProviderStatus); + } + + return Task.CompletedTask; + } +} \ No newline at end of file diff --git a/src/Application/Features/QualityAssurance/Queries/EnrolmentQaEscalationQueueEntrySpecification.cs b/src/Application/Features/QualityAssurance/Queries/EnrolmentQaEscalationQueueEntrySpecification.cs new file mode 100644 index 00000000..2fcc025e --- /dev/null +++ b/src/Application/Features/QualityAssurance/Queries/EnrolmentQaEscalationQueueEntrySpecification.cs @@ -0,0 +1,15 @@ +using Cfo.Cats.Domain.Entities.Participants; + +namespace Cfo.Cats.Application.Features.QualityAssurance.Queries; + +public class EnrolmentQaEscalationQueueEntrySpecification : Specification +{ + public EnrolmentQaEscalationQueueEntrySpecification(QueueEntryFilter filter) + { + Query.Where(e => e.TenantId + .StartsWith(filter.CurrentUser!.TenantId!)) + .Where(e => e.IsCompleted == false); + + Query.Where(e => e.ParticipantId.Contains(filter.Keyword!), string.IsNullOrWhiteSpace(filter.Keyword) == false); + } +} diff --git a/src/Application/Features/QualityAssurance/Queries/GetEscalationEntryById.cs b/src/Application/Features/QualityAssurance/Queries/GetEscalationEntryById.cs new file mode 100644 index 00000000..5e104d2d --- /dev/null +++ b/src/Application/Features/QualityAssurance/Queries/GetEscalationEntryById.cs @@ -0,0 +1,46 @@ +using Cfo.Cats.Application.Common.Security; +using Cfo.Cats.Application.Common.Validators; +using Cfo.Cats.Application.Features.QualityAssurance.DTOs; +using Cfo.Cats.Application.SecurityConstants; + +namespace Cfo.Cats.Application.Features.QualityAssurance.Queries; + +public static class GetEscalationEntryById +{ + [RequestAuthorize(Policy = SecurityPolicies.SeniorInternal)] + public class Query : IRequest> + { + public Guid Id { get; set; } + public UserProfile? CurrentUser { get; set; } + } + + public class Handler(IUnitOfWork unitOfWork, IMapper mapper) : IRequestHandler> + { + public async Task> Handle(Query request, CancellationToken cancellationToken) + { + var entry = await unitOfWork.DbContext.EnrolmentEscalationQueue + .Where(a => a.Id == request.Id && a.TenantId.StartsWith(request.CurrentUser!.TenantId!)) + .ProjectTo(mapper.ConfigurationProvider) + .FirstOrDefaultAsync(cancellationToken); + + if (entry == null) + { + //question: do we return a specific error if the entry exists but is at a different tenant? + return Result.Failure("Not found"); + } + + return entry; + + } + } + + public class Validator : AbstractValidator + { + public Validator() + { + RuleFor(r => r.Id) + .NotEmpty() + .WithMessage(string.Format(ValidationConstants.GuidMessage, "Id")); + } + } +} diff --git a/src/Application/Features/QualityAssurance/Queries/QaEscalationWithPaginiation.cs b/src/Application/Features/QualityAssurance/Queries/QaEscalationWithPaginiation.cs new file mode 100644 index 00000000..7627323c --- /dev/null +++ b/src/Application/Features/QualityAssurance/Queries/QaEscalationWithPaginiation.cs @@ -0,0 +1,97 @@ +using Cfo.Cats.Application.Common.Security; +using Cfo.Cats.Application.Common.Validators; +using Cfo.Cats.Application.Features.QualityAssurance.DTOs; +using Cfo.Cats.Application.SecurityConstants; +using Cfo.Cats.Domain.Entities.Participants; +namespace Cfo.Cats.Application.Features.QualityAssurance.Queries; + +public static class QaEscalationWithPaginiation +{ + [RequestAuthorize(Policy = SecurityPolicies.SeniorInternal)] + public class Query : QueueEntryFilter, IRequest> + { + public Query() + { + SortDirection = "Desc"; + OrderBy = "Created"; + } + public EnrolmentQaEscalationQueueEntrySpecification Specification => new(this); + } + + public class Handler(IUnitOfWork unitOfWork, IMapper mapper) : IRequestHandler> + { + public async Task> Handle(Query request, CancellationToken cancellationToken) + { + var query = unitOfWork.DbContext + .EnrolmentEscalationQueue + .AsNoTracking(); + + var sortExpression = GetSortExpression(request); + + var ordered = request.SortDirection.Equals("Descending", StringComparison.CurrentCultureIgnoreCase) + ? query.OrderByDescending(sortExpression) + : query.OrderBy(sortExpression); + + var data = await ordered + .ProjectToPaginatedDataAsync(request.Specification, request.PageNumber, request.PageSize, mapper.ConfigurationProvider, cancellationToken); + + return data; + } + + private Expression> GetSortExpression(Query request) + { + Expression> sortExpression; + switch (request.OrderBy) + { + case "ParticipantId": + sortExpression = (x => x.Participant!.FirstName + ' ' + x.Participant.LastName); + break; + case "TenantId": + sortExpression = (x => x.TenantId); + break; + case "Created": + sortExpression = (x => x.Created!); + break; + case "SupportWorker": + sortExpression = (x => x.Participant!.Owner!.DisplayName!); + break; + case "AssignedTo": + sortExpression = (x => x.OwnerId == null ? null : x.Owner!.DisplayName); + break; + default: + sortExpression = (x => x.Created!); + break; + } + + return sortExpression; + } + } + public class Validator : AbstractValidator + { + public Validator() + { + RuleFor(r => r.Keyword) + .Matches(ValidationConstants.Keyword) + .WithMessage(string.Format(ValidationConstants.KeywordMessage, "Search Keyword")); + + RuleFor(r => r.PageNumber) + .GreaterThan(0) + .WithMessage(string.Format(ValidationConstants.PositiveNumberMessage, "Page Number")); + + RuleFor(r => r.PageSize) + .GreaterThan(0) + .LessThanOrEqualTo(1000) + .WithMessage(string.Format(ValidationConstants.MaximumPageSizeMessage, "Page Size")); + + RuleFor(r => r.SortDirection) + .Matches(ValidationConstants.SortDirection) + .WithMessage(ValidationConstants.SortDirectionMessage); + + //May be at some point in future validate against columns of query result dataset + RuleFor(r => r.OrderBy) + .Matches(ValidationConstants.AlphaNumeric) + .WithMessage(string.Format(ValidationConstants.AlphaNumericMessage, "OrderBy")); + + } + } +} diff --git a/src/Application/SecurityConstants/SecurityPolicies.cs b/src/Application/SecurityConstants/SecurityPolicies.cs index 3f34a1a6..021f282e 100644 --- a/src/Application/SecurityConstants/SecurityPolicies.cs +++ b/src/Application/SecurityConstants/SecurityPolicies.cs @@ -17,6 +17,8 @@ public static class SecurityPolicies public const string Qa1 = nameof(Qa1); public const string Qa2 = nameof(Qa2); + + public const string SeniorInternal = nameof(SeniorInternal); /// /// The user is allowed to upload files. diff --git a/src/Domain/Entities/Participants/EnrolmentEscalationQueueEntry.cs b/src/Domain/Entities/Participants/EnrolmentEscalationQueueEntry.cs index 733210a7..2822f8ec 100644 --- a/src/Domain/Entities/Participants/EnrolmentEscalationQueueEntry.cs +++ b/src/Domain/Entities/Participants/EnrolmentEscalationQueueEntry.cs @@ -1,4 +1,6 @@ -namespace Cfo.Cats.Domain.Entities.Participants; +using Cfo.Cats.Domain.Events.QA.Enrolments; + +namespace Cfo.Cats.Domain.Entities.Participants; public class EnrolmentEscalationQueueEntry : EnrolmentQueueEntry { @@ -14,4 +16,20 @@ public static EnrolmentEscalationQueueEntry Create(string participantId) { return new EnrolmentEscalationQueueEntry(participantId); } + + public override EnrolmentQueueEntry Accept() + { + IsAccepted = true; + IsCompleted = true; + AddDomainEvent(new EnrolmentEscalationEntryCompletedDomainEvent(this)); + return this; + } + + public override EnrolmentQueueEntry Return() + { + IsAccepted = false; + IsCompleted = true; + AddDomainEvent(new EnrolmentEscalationEntryCompletedDomainEvent(this)); + return this; + } } \ No newline at end of file diff --git a/src/Domain/Entities/Participants/EnrolmentPqaQueueEntry.cs b/src/Domain/Entities/Participants/EnrolmentPqaQueueEntry.cs index 1fb138be..bf0840cf 100644 --- a/src/Domain/Entities/Participants/EnrolmentPqaQueueEntry.cs +++ b/src/Domain/Entities/Participants/EnrolmentPqaQueueEntry.cs @@ -1,21 +1,36 @@ using Cfo.Cats.Domain.Events; +using Cfo.Cats.Domain.Events.QA.Enrolments; namespace Cfo.Cats.Domain.Entities.Participants; public class EnrolmentPqaQueueEntry : EnrolmentQueueEntry { - private EnrolmentPqaQueueEntry() : this(string.Empty) + private EnrolmentPqaQueueEntry() + : this(string.Empty) { } + private EnrolmentPqaQueueEntry(string participantId) - : base(participantId) + : base(participantId) => + AddDomainEvent(new EnrolmentPqaQueueCreatedDomainEvent(this)); + + public static EnrolmentPqaQueueEntry Create(string participantId) => new(participantId); + + public override EnrolmentQueueEntry Accept() { - this.AddDomainEvent(new EnrolmentPqaQueueCreatedDomainEvent(this)); + IsAccepted = true; + IsCompleted = true; + AddDomainEvent(new EnrolmentPqaEntryCompletedDomainEvent(this)); + return this; } - - public static EnrolmentPqaQueueEntry Create(string participantId) + public override EnrolmentQueueEntry Return() { - return new EnrolmentPqaQueueEntry(participantId); + IsAccepted = false; + IsCompleted = true; + AddDomainEvent(new EnrolmentPqaEntryCompletedDomainEvent(this)); + return this; } + + } \ No newline at end of file diff --git a/src/Domain/Entities/Participants/EnrolmentQa1QueueEntry.cs b/src/Domain/Entities/Participants/EnrolmentQa1QueueEntry.cs index 9c1a1a1c..1dda8d1c 100644 --- a/src/Domain/Entities/Participants/EnrolmentQa1QueueEntry.cs +++ b/src/Domain/Entities/Participants/EnrolmentQa1QueueEntry.cs @@ -1,4 +1,5 @@ using Cfo.Cats.Domain.Events; +using Cfo.Cats.Domain.Events.QA.Enrolments; namespace Cfo.Cats.Domain.Entities.Participants; @@ -8,14 +9,25 @@ private EnrolmentQa1QueueEntry() : this(string.Empty) { } - private EnrolmentQa1QueueEntry(string participantId) : base(participantId) + private EnrolmentQa1QueueEntry(string participantId) : base(participantId) + => AddDomainEvent(new EnrolmentQa1QueueCreatedDomainEvent(this)); + + public static EnrolmentQa1QueueEntry Create(string participantId) => new(participantId); + + public override EnrolmentQueueEntry Accept() { - this.AddDomainEvent(new EnrolmentQa1QueueCreatedDomainEvent(this)); + IsAccepted = true; + IsCompleted = true; + AddDomainEvent(new EnrolmentQa1EntryCompletedDomainEvent(this)); + return this; } - - public static EnrolmentQa1QueueEntry Create(string participantId) + + public override EnrolmentQueueEntry Return() { - return new EnrolmentQa1QueueEntry(participantId); + IsAccepted = false; + IsCompleted = true; + AddDomainEvent(new EnrolmentQa1EntryCompletedDomainEvent(this)); + return this; } } \ No newline at end of file diff --git a/src/Domain/Entities/Participants/EnrolmentQa2QueueEntry.cs b/src/Domain/Entities/Participants/EnrolmentQa2QueueEntry.cs index 4807a8d4..bd8aa6b2 100644 --- a/src/Domain/Entities/Participants/EnrolmentQa2QueueEntry.cs +++ b/src/Domain/Entities/Participants/EnrolmentQa2QueueEntry.cs @@ -1,4 +1,5 @@ using Cfo.Cats.Domain.Events; +using Cfo.Cats.Domain.Events.QA.Enrolments; namespace Cfo.Cats.Domain.Entities.Participants; @@ -9,14 +10,37 @@ private EnrolmentQa2QueueEntry() : this(string.Empty) } - private EnrolmentQa2QueueEntry(string participantId) : base(participantId) + public bool IsEscalated { get; private set; } + + private EnrolmentQa2QueueEntry(string participantId) : base(participantId) + => AddDomainEvent(new EnrolmentQa2QueueCreatedDomainEvent(this)); + + public static EnrolmentQa2QueueEntry Create(string participantId) + => new(participantId); + + public override EnrolmentQueueEntry Accept() { - this.AddDomainEvent(new EnrolmentQa2QueueCreatedDomainEvent(this)); + IsAccepted = true; + IsCompleted = true; + AddDomainEvent(new EnrolmentQa2EntryCompletedDomainEvent(this)); + return this; } - - public static EnrolmentQa2QueueEntry Create(string participantId) + + public override EnrolmentQueueEntry Return() { - return new EnrolmentQa2QueueEntry(participantId); + IsAccepted = false; + IsCompleted = true; + AddDomainEvent(new EnrolmentQa2EntryCompletedDomainEvent(this)); + return this; } + public EnrolmentQueueEntry Escalate() + { + IsCompleted = true; + IsAccepted = false; + IsEscalated = true; + AddDomainEvent(new EnrolmentQa2EntryEscalatedDomainEvent(this)); + return this; + } + } \ No newline at end of file diff --git a/src/Domain/Entities/Participants/EnrolmentQueueEntry.cs b/src/Domain/Entities/Participants/EnrolmentQueueEntry.cs index d471e0ad..124854cb 100644 --- a/src/Domain/Entities/Participants/EnrolmentQueueEntry.cs +++ b/src/Domain/Entities/Participants/EnrolmentQueueEntry.cs @@ -12,8 +12,8 @@ public abstract class EnrolmentQueueEntry : OwnerPropertyEntity, IMustHave { private readonly List _notes = []; - public bool IsAccepted { get; private set; } - public bool IsCompleted { get; private set; } + public bool IsAccepted { get; protected set; } + public bool IsCompleted { get; protected set; } public string ParticipantId { get; private set; } #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. @@ -33,24 +33,12 @@ protected EnrolmentQueueEntry(string participantId) public virtual Tenant? Tenant { get; private set; } public IReadOnlyCollection Notes => _notes.AsReadOnly(); - - public EnrolmentQueueEntry AddNote(Note note) - { - if(_notes.Contains(note) is false) - { - _notes.Add(note); - } - return this; - } + public abstract EnrolmentQueueEntry Accept(); - public EnrolmentQueueEntry Complete(bool accept) - { - IsCompleted = true; - IsAccepted = accept; - AddDomainEvent(new EnrolmentQueueEntryCompletedDomainEvent(this)); - return this; - } + + public abstract EnrolmentQueueEntry Return(); + public EnrolmentQueueEntry AddNote(string? message) { @@ -65,7 +53,5 @@ public EnrolmentQueueEntry AddNote(string? message) return this; } - - public string TenantId { get; set; } = default!; } diff --git a/src/Domain/Events/EnrlomenentQueueEntryCompletedDomainEvent.cs b/src/Domain/Events/EnrlomenentQueueEntryCompletedDomainEvent.cs deleted file mode 100644 index 9a221f59..00000000 --- a/src/Domain/Events/EnrlomenentQueueEntryCompletedDomainEvent.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Cfo.Cats.Domain.Entities.Participants; - -namespace Cfo.Cats.Domain.Events; - -public sealed class EnrolmentQueueEntryCompletedDomainEvent(EnrolmentQueueEntry entry) - : DomainEvent -{ - public EnrolmentQueueEntry Entry { get; } = entry; -} diff --git a/src/Domain/Events/QA/Enrolments/EnrolmentEscalationEntryCompletedDomainEvent.cs b/src/Domain/Events/QA/Enrolments/EnrolmentEscalationEntryCompletedDomainEvent.cs new file mode 100644 index 00000000..a1cf6d52 --- /dev/null +++ b/src/Domain/Events/QA/Enrolments/EnrolmentEscalationEntryCompletedDomainEvent.cs @@ -0,0 +1,8 @@ +using Cfo.Cats.Domain.Entities.Participants; + +namespace Cfo.Cats.Domain.Events.QA.Enrolments; + +public sealed class EnrolmentEscalationEntryCompletedDomainEvent(EnrolmentEscalationQueueEntry entry) : DomainEvent +{ + public EnrolmentEscalationQueueEntry Entry { get; } = entry; +} \ No newline at end of file diff --git a/src/Domain/Events/QA/Enrolments/EnrolmentPqaEntryCompletedDomainEvent.cs b/src/Domain/Events/QA/Enrolments/EnrolmentPqaEntryCompletedDomainEvent.cs new file mode 100644 index 00000000..c565b15a --- /dev/null +++ b/src/Domain/Events/QA/Enrolments/EnrolmentPqaEntryCompletedDomainEvent.cs @@ -0,0 +1,9 @@ +using Cfo.Cats.Domain.Entities.Participants; + +namespace Cfo.Cats.Domain.Events.QA.Enrolments; + + +public sealed class EnrolmentPqaEntryCompletedDomainEvent(EnrolmentPqaQueueEntry entry) : DomainEvent +{ + public EnrolmentPqaQueueEntry Entry { get; } = entry; +} \ No newline at end of file diff --git a/src/Domain/Events/QA/Enrolments/EnrolmentQa1EntryCompletedDomainEvent.cs b/src/Domain/Events/QA/Enrolments/EnrolmentQa1EntryCompletedDomainEvent.cs new file mode 100644 index 00000000..b126152e --- /dev/null +++ b/src/Domain/Events/QA/Enrolments/EnrolmentQa1EntryCompletedDomainEvent.cs @@ -0,0 +1,8 @@ +using Cfo.Cats.Domain.Entities.Participants; + +namespace Cfo.Cats.Domain.Events.QA.Enrolments; + +public sealed class EnrolmentQa1EntryCompletedDomainEvent(EnrolmentQa1QueueEntry entry) : DomainEvent +{ + public EnrolmentQa1QueueEntry Entry { get; } = entry; +} \ No newline at end of file diff --git a/src/Domain/Events/QA/Enrolments/EnrolmentQa2EntryCompletedDomainEvent.cs b/src/Domain/Events/QA/Enrolments/EnrolmentQa2EntryCompletedDomainEvent.cs new file mode 100644 index 00000000..e579c534 --- /dev/null +++ b/src/Domain/Events/QA/Enrolments/EnrolmentQa2EntryCompletedDomainEvent.cs @@ -0,0 +1,8 @@ +using Cfo.Cats.Domain.Entities.Participants; + +namespace Cfo.Cats.Domain.Events.QA.Enrolments; + +public sealed class EnrolmentQa2EntryCompletedDomainEvent(EnrolmentQa2QueueEntry entry) : DomainEvent +{ + public EnrolmentQa2QueueEntry Entry { get; } = entry; +} \ No newline at end of file diff --git a/src/Domain/Events/QA/Enrolments/EnrolmentQa2EntryEscalatedDomainEvent.cs b/src/Domain/Events/QA/Enrolments/EnrolmentQa2EntryEscalatedDomainEvent.cs new file mode 100644 index 00000000..e10d9702 --- /dev/null +++ b/src/Domain/Events/QA/Enrolments/EnrolmentQa2EntryEscalatedDomainEvent.cs @@ -0,0 +1,9 @@ +using Cfo.Cats.Domain.Entities.Participants; + +namespace Cfo.Cats.Domain.Events.QA.Enrolments; + +public sealed class EnrolmentQa2EntryEscalatedDomainEvent(EnrolmentQa2QueueEntry entry) : DomainEvent +{ + public EnrolmentQa2QueueEntry Entry { get; } = entry; +} + diff --git a/src/Infrastructure/DependencyInjection.cs b/src/Infrastructure/DependencyInjection.cs index 37303a4f..798a3d32 100644 --- a/src/Infrastructure/DependencyInjection.cs +++ b/src/Infrastructure/DependencyInjection.cs @@ -316,6 +316,12 @@ private static IServiceCollection AddAuthenticationService(this IServiceCollecti policy.RequireClaim(ApplicationClaimTypes.AccountLocked, "False"); policy.RequireRole(RoleNames.SystemSupport, RoleNames.SMT, RoleNames.QAManager, RoleNames.QAOfficer, RoleNames.QASupportManager, RoleNames.QAFinance); }); + + options.AddPolicy(SecurityPolicies.SeniorInternal, policy => { + policy.RequireAuthenticatedUser(); + policy.RequireClaim(ApplicationClaimTypes.AccountLocked, "False"); + policy.RequireRole(RoleNames.SystemSupport, RoleNames.SMT, RoleNames.QAManager); + }); }) .AddAuthentication(options => { options.DefaultScheme = IdentityConstants.ApplicationScheme; diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20241008091311_QA_EscalationFlag.Designer.cs b/src/Migrators/Migrators.MSSQL/Migrations/20241008091311_QA_EscalationFlag.Designer.cs new file mode 100644 index 00000000..5d70e34b --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20241008091311_QA_EscalationFlag.Designer.cs @@ -0,0 +1,2983 @@ +// +using System; +using Cfo.Cats.Infrastructure.Persistence; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Cfo.Cats.Migrators.MSSQL.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20241008091311_QA_EscalationFlag")] + partial class QA_EscalationFlag + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Contract", b => + { + b.Property("Id") + .HasMaxLength(12) + .HasColumnType("nvarchar(12)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LotNumber") + .HasColumnType("int"); + + b.Property("_tenantId") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("LotNumber") + .IsUnique(); + + b.HasIndex("_tenantId"); + + b.ToTable("Contract", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Location", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("_contractId") + .HasMaxLength(12) + .HasColumnType("nvarchar(12)") + .HasColumnName("ContractId"); + + b.Property("_genderProvisionId") + .HasColumnType("int") + .HasColumnName("GenderProvisionId"); + + b.Property("_locationTypeId") + .HasColumnType("int") + .HasColumnName("LocationTypeId"); + + b.Property("_parentLocationId") + .HasColumnType("int") + .HasColumnName("ParentLocationId"); + + b.HasKey("Id"); + + b.HasIndex("_contractId"); + + b.HasIndex("_parentLocationId"); + + b.ToTable("Location", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.LocationMapping", b => + { + b.Property("Code") + .HasMaxLength(3) + .HasColumnType("nvarchar(3)"); + + b.Property("CodeType") + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("DeliveryRegion") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("_locationId") + .HasColumnType("int") + .HasColumnName("LocationId"); + + b.HasKey("Code", "CodeType"); + + b.HasIndex("_locationId"); + + b.ToTable("LocationMapping", "Dms"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Tenant", b => + { + b.Property("Id") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.ToTable("Tenant", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Assessments.ParticipantAssessment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("AssessmentJson") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Completed") + .HasColumnType("datetime2"); + + b.Property("CompletedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("Assessment", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.AuditTrail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AffectedColumns") + .HasColumnType("nvarchar(max)"); + + b.Property("AuditType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DateTime") + .HasColumnType("datetime2"); + + b.Property("NewValues") + .HasColumnType("nvarchar(max)"); + + b.Property("OldValues") + .HasColumnType("nvarchar(max)"); + + b.Property("PrimaryKey") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TableName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AuditTrail", "Audit"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Bios.ParticipantBio", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("BioJson") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Completed") + .HasColumnType("datetime2"); + + b.Property("CompletedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("Status") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("Bio", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Documents.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Content") + .HasMaxLength(4000) + .HasColumnType("nvarchar(4000)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("DocumentType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("IsPublic") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("OwnerId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("TenantId") + .HasColumnType("nvarchar(50)"); + + b.Property("Title") + .HasColumnType("nvarchar(max)"); + + b.Property("URL") + .HasColumnType("nvarchar(max)"); + + b.Property("Version") + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("LastModifiedBy"); + + b.HasIndex("TenantId"); + + b.ToTable("Document", "Document"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.IdentityAuditTrail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ActionType") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("DateTime") + .HasColumnType("datetime2"); + + b.Property("IpAddress") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("PerformedBy") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UserName") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("UserName", "DateTime") + .HasDatabaseName("idx_IdentityAudit_UserName_DateTime"); + + b.ToTable("IdentityAuditTrail", "Audit"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Inductions.HubInduction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("InductionDate") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("OwnerId") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("CreatedBy"); + + b.HasIndex("EditorId"); + + b.HasIndex("LocationId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId", "Created"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("ParticipantId", "Created")); + + b.ToTable("HubInduction", "Induction"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Inductions.WingInduction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("InductionDate") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("OwnerId") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("CreatedBy"); + + b.HasIndex("EditorId"); + + b.HasIndex("LocationId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId", "Created"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex("ParticipantId", "Created")); + + b.ToTable("WingInduction", "Induction"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.KeyValue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Text") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("KeyValue", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.ParticipantAccessAuditTrail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AccessDate") + .HasColumnType("datetime2"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("RequestType") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("AccessAuditTrail", "Audit"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentEscalationQueueEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("IsAccepted") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("EscalationQueue", "Enrolment"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentPqaQueueEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("IsAccepted") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("PqaQueue", "Enrolment"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa1QueueEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("IsAccepted") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("Qa1Queue", "Enrolment"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa2QueueEntry", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("IsAccepted") + .HasColumnType("bit"); + + b.Property("IsCompleted") + .HasColumnType("bit"); + + b.Property("IsEscalated") + .HasColumnType("bit"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b.Property("OwnerId") + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("Qa2Queue", "Enrolment"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Participant", b => + { + b.Property("Id") + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.Property("ActiveInFeed") + .HasColumnType("bit"); + + b.Property("AssessmentJustification") + .HasColumnType("nvarchar(max)"); + + b.Property("ConsentStatus") + .HasColumnType("int"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("DateOfBirth") + .HasColumnType("date"); + + b.Property("EditorId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("EnrolmentLocationJustification") + .HasColumnType("nvarchar(max)"); + + b.Property("EnrolmentStatus") + .HasColumnType("int"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Gender") + .HasMaxLength(6) + .HasColumnType("nvarchar(6)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MiddleName") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Nationality") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("OwnerId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ReferralComments") + .HasColumnType("nvarchar(max)"); + + b.Property("ReferralSource") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("RegistrationDetailsJson") + .HasColumnType("nvarchar(max)"); + + b.Property("RiskDue") + .HasColumnType("datetime2"); + + b.Property("_currentLocationId") + .HasColumnType("int") + .HasColumnName("CurrentLocationId"); + + b.Property("_enrolmentLocationId") + .HasColumnType("int") + .HasColumnName("EnrolmentLocationId"); + + b.HasKey("Id"); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("_currentLocationId"); + + b.HasIndex("_enrolmentLocationId"); + + b.ToTable("Participant", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.ParticipantEnrolmentHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("EnrolmentStatus") + .HasColumnType("int"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("EnrolmentHistory", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.PathwayPlan", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasMaxLength(9) + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("PathwayPlan", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Risk", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b.Property("ActivityRecommendations") + .HasColumnType("nvarchar(max)"); + + b.Property("ActivityRecommendationsReceived") + .HasColumnType("datetime2"); + + b.Property("ActivityRestrictions") + .HasColumnType("nvarchar(max)"); + + b.Property("ActivityRestrictionsReceived") + .HasColumnType("datetime2"); + + b.Property("AdditionalInformation") + .HasColumnType("nvarchar(max)"); + + b.Property("Completed") + .HasColumnType("datetime2"); + + b.Property("CompletedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("IsRelevantToCommunity") + .HasColumnType("bit"); + + b.Property("IsRelevantToCustody") + .HasColumnType("bit"); + + b.Property("IsSubjectToSHPO") + .HasColumnType("int"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LicenseConditions") + .HasColumnType("nvarchar(max)"); + + b.Property("LicenseEnd") + .HasColumnType("datetime2"); + + b.Property("NSDCase") + .HasColumnType("int"); + + b.Property("PSFRestrictions") + .HasColumnType("nvarchar(max)"); + + b.Property("PSFRestrictionsReceived") + .HasColumnType("datetime2"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.Property("ReferredOn") + .HasColumnType("datetime2"); + + b.Property("ReferrerEmail") + .HasColumnType("nvarchar(max)"); + + b.Property("ReferrerName") + .HasColumnType("nvarchar(max)"); + + b.Property("RegistrationDetailsJson") + .HasColumnType("nvarchar(max)"); + + b.Property("ReviewJustification") + .HasColumnType("nvarchar(max)"); + + b.Property("ReviewReason") + .HasColumnType("int"); + + b.Property("RiskToChildrenInCommunity") + .HasColumnType("int"); + + b.Property("RiskToChildrenInCustody") + .HasColumnType("int"); + + b.Property("RiskToKnownAdultInCommunity") + .HasColumnType("int"); + + b.Property("RiskToKnownAdultInCustody") + .HasColumnType("int"); + + b.Property("RiskToOtherPrisonersInCustody") + .HasColumnType("int"); + + b.Property("RiskToPublicInCommunity") + .HasColumnType("int"); + + b.Property("RiskToPublicInCustody") + .HasColumnType("int"); + + b.Property("RiskToSelfInCommunity") + .HasColumnType("int"); + + b.Property("RiskToSelfInCustody") + .HasColumnType("int"); + + b.Property("RiskToStaffInCommunity") + .HasColumnType("int"); + + b.Property("RiskToStaffInCustody") + .HasColumnType("int"); + + b.Property("SpecificRisk") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ParticipantId"); + + b.ToTable("Risk", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Timeline", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .HasColumnType("nvarchar(36)"); + + b.Property("EventType") + .HasColumnType("int"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Line1") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Line2") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Line3") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ParticipantId"); + + b.ToTable("Timeline", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRole", b => + { + b.Property("Id") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("NormalizedName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RoleRank") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("Role", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Group") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RoleId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("RoleClaim", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUser", b => + { + b.Property("Id") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("AccessFailedCount") + .HasColumnType("int"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("nvarchar(max)"); + + b.Property("Created") + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("DisplayName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("bit"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsLive") + .HasColumnType("bit"); + + b.Property("LastLogin") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LockoutEnabled") + .HasColumnType("bit"); + + b.Property("LockoutEnd") + .HasColumnType("datetimeoffset"); + + b.Property("MemorableDate") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MemorablePlace") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("PhoneNumber") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("bit"); + + b.Property("ProfilePictureDataUrl") + .HasColumnType("text"); + + b.Property("ProviderId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RefreshToken") + .HasColumnType("nvarchar(max)"); + + b.Property("RefreshTokenExpiryTime") + .HasColumnType("datetime2"); + + b.Property("RequiresPasswordReset") + .HasColumnType("bit"); + + b.Property("SecurityStamp") + .HasColumnType("nvarchar(max)"); + + b.Property("SuperiorId") + .HasColumnType("nvarchar(36)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TenantName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("TwoFactorEnabled") + .HasColumnType("bit"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex") + .HasFilter("[NormalizedUserName] IS NOT NULL"); + + b.HasIndex("SuperiorId"); + + b.HasIndex("TenantId"); + + b.ToTable("User", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("nvarchar(max)"); + + b.Property("ClaimValue") + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserClaim", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserRole", b => + { + b.Property("UserId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("RoleId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("UserRole", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserToken", b => + { + b.Property("UserId") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("Name") + .HasColumnType("nvarchar(450)"); + + b.Property("Value") + .HasColumnType("nvarchar(max)"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("UserToken", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.PasswordHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("Id"); + + b.ToTable("PasswordHistory", "Identity"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.UserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderKey") + .HasColumnType("nvarchar(450)"); + + b.Property("ProviderDisplayName") + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("UserLogin", "Identity"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.DataProtection.EntityFrameworkCore.DataProtectionKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("FriendlyName") + .HasColumnType("nvarchar(max)"); + + b.Property("Xml") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("DataProtectionKeys"); + }); + + modelBuilder.Entity("TenantLocation", b => + { + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("TenantId") + .HasColumnType("nvarchar(50)"); + + b.HasKey("LocationId", "TenantId"); + + b.HasIndex("TenantId"); + + b.ToTable("TenantLocation", "Configuration"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Contract", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("_tenantId"); + + b.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b1 => + { + b1.Property("ContractId") + .HasColumnType("nvarchar(12)"); + + b1.Property("EndDate") + .HasColumnType("datetime2") + .HasColumnName("LifetimeEnd"); + + b1.Property("StartDate") + .HasColumnType("datetime2") + .HasColumnName("LifetimeStart"); + + b1.HasKey("ContractId"); + + b1.ToTable("Contract", "Configuration"); + + b1.WithOwner() + .HasForeignKey("ContractId"); + }); + + b.Navigation("Lifetime") + .IsRequired(); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Location", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Contract", "Contract") + .WithMany("Locations") + .HasForeignKey("_contractId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "ParentLocation") + .WithMany("ChildLocations") + .HasForeignKey("_parentLocationId") + .OnDelete(DeleteBehavior.Restrict); + + b.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b1 => + { + b1.Property("LocationId") + .HasColumnType("int"); + + b1.Property("EndDate") + .HasColumnType("datetime2") + .HasColumnName("LifetimeEnd"); + + b1.Property("StartDate") + .HasColumnType("datetime2") + .HasColumnName("LifetimeStart"); + + b1.HasKey("LocationId"); + + b1.ToTable("Location", "Configuration"); + + b1.WithOwner() + .HasForeignKey("LocationId"); + }); + + b.Navigation("Contract"); + + b.Navigation("Lifetime") + .IsRequired(); + + b.Navigation("ParentLocation"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.LocationMapping", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "Location") + .WithMany("LocationMappings") + .HasForeignKey("_locationId"); + + b.Navigation("Location"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Tenant", b => + { + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.TenantDomain", "Domains", b1 => + { + b1.Property("TenantId") + .HasColumnType("nvarchar(50)"); + + b1.Property("Domain") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.HasKey("TenantId", "Domain"); + + b1.ToTable("TenantDomain", "Configuration"); + + b1.WithOwner() + .HasForeignKey("TenantId"); + }); + + b.Navigation("Domains"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Assessments.ParticipantAssessment", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", null) + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.PathwayScore", "Scores", b1 => + { + b1.Property("AssessmentId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Pathway") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b1.Property("Score") + .HasColumnType("float"); + + b1.HasKey("AssessmentId", "Pathway"); + + b1.ToTable("AssessmentPathwayScore", "Participant"); + + b1.WithOwner() + .HasForeignKey("AssessmentId"); + }); + + b.Navigation("Editor"); + + b.Navigation("Owner"); + + b.Navigation("Scores"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.AuditTrail", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.SetNull); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Bios.ParticipantBio", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Documents.Document", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("LastModifiedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Editor"); + + b.Navigation("Owner"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Inductions.HubInduction", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Editor"); + + b.Navigation("Location"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Inductions.WingInduction", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "Location") + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.Entities.Inductions.InductionPhase", "Phases", b1 => + { + b1.Property("WingInductionId") + .HasColumnType("uniqueidentifier"); + + b1.Property("Number") + .HasColumnType("int"); + + b1.Property("CompletedDate") + .HasColumnType("datetime2"); + + b1.Property("StartDate") + .HasColumnType("datetime2"); + + b1.HasKey("WingInductionId", "Number"); + + b1.ToTable("WingInductionPhase", "Induction"); + + b1.WithOwner() + .HasForeignKey("WingInductionId"); + }); + + b.Navigation("Editor"); + + b.Navigation("Location"); + + b.Navigation("Owner"); + + b.Navigation("Phases"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.ParticipantAccessAuditTrail", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentEscalationQueueEntry", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("EnrolmentEscalationQueueEntryId") + .HasColumnType("uniqueidentifier"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("EnrolmentEscalationQueueEntryId"); + + b1.HasIndex("LastModifiedBy"); + + b1.ToTable("EscalationNote", "Enrolment"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.WithOwner() + .HasForeignKey("EnrolmentEscalationQueueEntryId"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Editor"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("Participant"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentPqaQueueEntry", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("EnrolmentPqaQueueEntryId") + .HasColumnType("uniqueidentifier"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("EnrolmentPqaQueueEntryId"); + + b1.HasIndex("LastModifiedBy"); + + b1.ToTable("PqaQueueNote", "Enrolment"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.WithOwner() + .HasForeignKey("EnrolmentPqaQueueEntryId"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Editor"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("Participant"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa1QueueEntry", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("EnrolmentQa1QueueEntryId") + .HasColumnType("uniqueidentifier"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("EnrolmentQa1QueueEntryId"); + + b1.HasIndex("LastModifiedBy"); + + b1.ToTable("Qa1QueueNote", "Enrolment"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.WithOwner() + .HasForeignKey("EnrolmentQa1QueueEntryId"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Editor"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("Participant"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.EnrolmentQa2QueueEntry", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("EnrolmentQa2QueueEntryId") + .HasColumnType("uniqueidentifier"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("EnrolmentQa2QueueEntryId"); + + b1.HasIndex("LastModifiedBy"); + + b1.ToTable("Qa2QueueNote", "Enrolment"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.WithOwner() + .HasForeignKey("EnrolmentQa2QueueEntryId"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Editor"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("Participant"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Participant", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "CurrentLocation") + .WithMany() + .HasForeignKey("_currentLocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired() + .HasConstraintName("FK_Participant_Location"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", "EnrolmentLocation") + .WithMany() + .HasForeignKey("_enrolmentLocationId") + .HasConstraintName("FK_Participant_EnrolmentLocation"); + + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.Consent", "Consents", b1 => + { + b1.Property("ParticipantId") + .HasColumnType("nvarchar(9)"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("_documentId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DocumentId"); + + b1.HasKey("ParticipantId", "Id"); + + b1.HasIndex("_documentId"); + + b1.ToTable("Consent", "Participant"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + + b1.HasOne("Cfo.Cats.Domain.Entities.Documents.Document", "Document") + .WithMany() + .HasForeignKey("_documentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b1.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b2 => + { + b2.Property("ConsentParticipantId") + .HasColumnType("nvarchar(9)"); + + b2.Property("ConsentId") + .HasColumnType("int"); + + b2.Property("EndDate") + .HasColumnType("datetime2") + .HasColumnName("ValidTo"); + + b2.Property("StartDate") + .HasColumnType("datetime2") + .HasColumnName("ValidFrom"); + + b2.HasKey("ConsentParticipantId", "ConsentId"); + + b2.ToTable("Consent", "Participant"); + + b2.WithOwner() + .HasForeignKey("ConsentParticipantId", "ConsentId"); + }); + + b1.Navigation("Document"); + + b1.Navigation("Lifetime") + .IsRequired(); + }); + + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.ExternalIdentifier", "ExternalIdentifiers", b1 => + { + b1.Property("Value") + .HasMaxLength(16) + .HasColumnType("nvarchar(16)"); + + b1.Property("Type") + .HasColumnType("int"); + + b1.Property("ParticipantId") + .HasColumnType("nvarchar(9)"); + + b1.HasKey("Value", "Type", "ParticipantId"); + + b1.HasIndex("ParticipantId"); + + b1.ToTable("ExternalIdentifier", "Participant"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + }); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b1.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("LastModifiedBy"); + + b1.HasIndex("ParticipantId"); + + b1.ToTable("Note", "Participant"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.RightToWork", "RightToWorks", b1 => + { + b1.Property("ParticipantId") + .HasColumnType("nvarchar(9)"); + + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("_documentId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DocumentId"); + + b1.HasKey("ParticipantId", "Id"); + + b1.HasIndex("_documentId"); + + b1.ToTable("RightToWork", "Participant"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + + b1.HasOne("Cfo.Cats.Domain.Entities.Documents.Document", "Document") + .WithMany() + .HasForeignKey("_documentId"); + + b1.OwnsOne("Cfo.Cats.Domain.ValueObjects.Lifetime", "Lifetime", b2 => + { + b2.Property("RightToWorkParticipantId") + .HasColumnType("nvarchar(9)"); + + b2.Property("RightToWorkId") + .HasColumnType("int"); + + b2.Property("EndDate") + .HasColumnType("datetime2") + .HasColumnName("ValidTo"); + + b2.Property("StartDate") + .HasColumnType("datetime2") + .HasColumnName("ValidFrom"); + + b2.HasKey("RightToWorkParticipantId", "RightToWorkId"); + + b2.ToTable("RightToWork", "Participant"); + + b2.WithOwner() + .HasForeignKey("RightToWorkParticipantId", "RightToWorkId"); + }); + + b1.Navigation("Document"); + + b1.Navigation("Lifetime") + .IsRequired(); + }); + + b.OwnsOne("Cfo.Cats.Domain.Entities.Participants.Supervisor", "Supervisor", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b1.Property("Address") + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasColumnType("nvarchar(max)"); + + b1.Property("EmailAddress") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasColumnType("nvarchar(max)"); + + b1.Property("MobileNumber") + .HasMaxLength(16) + .HasColumnType("nvarchar(16)"); + + b1.Property("Name") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b1.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b1.Property("TelephoneNumber") + .HasMaxLength(16) + .HasColumnType("nvarchar(16)"); + + b1.HasKey("Id"); + + b1.HasIndex("ParticipantId") + .IsUnique(); + + b1.ToTable("Supervisor", "Participant"); + + b1.WithOwner() + .HasForeignKey("ParticipantId"); + }); + + b.Navigation("Consents"); + + b.Navigation("CurrentLocation"); + + b.Navigation("Editor"); + + b.Navigation("EnrolmentLocation"); + + b.Navigation("ExternalIdentifiers"); + + b.Navigation("Notes"); + + b.Navigation("Owner"); + + b.Navigation("RightToWorks"); + + b.Navigation("Supervisor"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.PathwayPlan", b => + { + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.Objective", "Objectives", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b1.Property("Completed") + .HasColumnType("datetime2"); + + b1.Property("CompletedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("CompletedStatus") + .HasColumnType("int"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("Index") + .HasColumnType("int"); + + b1.Property("Justification") + .HasColumnType("nvarchar(max)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("PathwayPlanId") + .HasColumnType("uniqueidentifier"); + + b1.HasKey("Id"); + + b1.HasIndex("CompletedBy"); + + b1.HasIndex("PathwayPlanId"); + + b1.ToTable("Objective", "Participant"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CompletedByUser") + .WithMany() + .HasForeignKey("CompletedBy"); + + b1.WithOwner() + .HasForeignKey("PathwayPlanId"); + + b1.OwnsMany("Cfo.Cats.Domain.Entities.Participants.ObjectiveTask", "Tasks", b2 => + { + b2.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b2.Property("Completed") + .HasColumnType("datetime2"); + + b2.Property("CompletedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b2.Property("CompletedStatus") + .HasColumnType("int"); + + b2.Property("Created") + .HasColumnType("datetime2"); + + b2.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b2.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b2.Property("Due") + .HasColumnType("datetime2"); + + b2.Property("Index") + .HasColumnType("int"); + + b2.Property("Justification") + .HasColumnType("nvarchar(max)"); + + b2.Property("LastModified") + .HasColumnType("datetime2"); + + b2.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b2.Property("ObjectiveId") + .HasColumnType("uniqueidentifier"); + + b2.HasKey("Id"); + + b2.HasIndex("CompletedBy"); + + b2.HasIndex("ObjectiveId"); + + b2.ToTable("ObjectiveTask", "Participant"); + + b2.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CompletedByUser") + .WithMany() + .HasForeignKey("CompletedBy"); + + b2.WithOwner() + .HasForeignKey("ObjectiveId"); + + b2.Navigation("CompletedByUser"); + }); + + b1.Navigation("CompletedByUser"); + + b1.Navigation("Tasks"); + }); + + b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.PathwayPlanReviewHistory", "ReviewHistories", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("PathwayPlanId") + .HasColumnType("uniqueidentifier"); + + b1.HasKey("Id"); + + b1.HasIndex("PathwayPlanId"); + + b1.ToTable("PathwayPlanReviewHistory", "Participant"); + + b1.WithOwner() + .HasForeignKey("PathwayPlanId"); + }); + + b.Navigation("Objectives"); + + b.Navigation("ReviewHistories"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Risk", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", "Participant") + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.Timeline", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByUser"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRoleClaim", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationRole", "Role") + .WithMany("RoleClaims") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUser", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Superior") + .WithMany() + .HasForeignKey("SuperiorId"); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.OwnsMany("Cfo.Cats.Domain.ValueObjects.Note", "Notes", b1 => + { + b1.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property("Id")); + + b1.Property("CallReference") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b1.Property("Created") + .HasColumnType("datetime2"); + + b1.Property("CreatedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("LastModified") + .HasColumnType("datetime2"); + + b1.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.Property("Message") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b1.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b1.Property("UserId") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b1.HasKey("Id"); + + b1.HasIndex("CreatedBy"); + + b1.HasIndex("LastModifiedBy"); + + b1.HasIndex("UserId"); + + b1.ToTable("Note", "Identity"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "CreatedByUser") + .WithMany() + .HasForeignKey("CreatedBy"); + + b1.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "LastModifiedByUser") + .WithMany() + .HasForeignKey("LastModifiedBy"); + + b1.WithOwner() + .HasForeignKey("UserId"); + + b1.Navigation("CreatedByUser"); + + b1.Navigation("LastModifiedByUser"); + }); + + b.Navigation("Notes"); + + b.Navigation("Superior"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserClaim", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") + .WithMany("UserClaims") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserRole", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationRole", "Role") + .WithMany("UserRoles") + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") + .WithMany("UserRoles") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUserToken", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") + .WithMany("Tokens") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.UserLogin", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "User") + .WithMany("Logins") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("User"); + }); + + modelBuilder.Entity("TenantLocation", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", null) + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", null) + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Contract", b => + { + b.Navigation("Locations"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Administration.Location", b => + { + b.Navigation("ChildLocations"); + + b.Navigation("LocationMappings"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationRole", b => + { + b.Navigation("RoleClaims"); + + b.Navigation("UserRoles"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Identity.ApplicationUser", b => + { + b.Navigation("Logins"); + + b.Navigation("Tokens"); + + b.Navigation("UserClaims"); + + b.Navigation("UserRoles"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20241008091311_QA_EscalationFlag.cs b/src/Migrators/Migrators.MSSQL/Migrations/20241008091311_QA_EscalationFlag.cs new file mode 100644 index 00000000..2dd631d7 --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20241008091311_QA_EscalationFlag.cs @@ -0,0 +1,31 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Cfo.Cats.Migrators.MSSQL.Migrations +{ + /// + public partial class QA_EscalationFlag : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "IsEscalated", + schema: "Enrolment", + table: "Qa2Queue", + type: "bit", + nullable: false, + defaultValue: false); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "IsEscalated", + schema: "Enrolment", + table: "Qa2Queue"); + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs b/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs index 196c84b0..ee98e97f 100644 --- a/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs @@ -803,6 +803,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("IsCompleted") .HasColumnType("bit"); + b.Property("IsEscalated") + .HasColumnType("bit"); + b.Property("LastModified") .HasColumnType("datetime2"); diff --git a/src/Server.UI/Pages/QA/Enrolments/Components/EscalationList.razor b/src/Server.UI/Pages/QA/Enrolments/Components/EscalationList.razor new file mode 100644 index 00000000..b9485aca --- /dev/null +++ b/src/Server.UI/Pages/QA/Enrolments/Components/EscalationList.razor @@ -0,0 +1,194 @@ +@using Cfo.Cats.Application.SecurityConstants +@using Humanizer + + +@using Cfo.Cats.Application.Features.QualityAssurance.DTOs +@using Cfo.Cats.Application.Features.QualityAssurance.Queries +@inherits CatsComponentBase; + +@inject IStringLocalizer L + + + + + + +
+
+ + Escalation +
+
+
+
+ + + @ConstantString.Refresh + + + + + +
+ + +
+
+
+ + + + + + + @ConstantString.View Enrolment + + + @ConstantString.View Participant + + + + + + + +
+ @context.Item.ParticipantName + @context.Item.ParticipantId +
+
+
+ + +
+ @context.Item.SupportWorker +
+
+
+ + +
+ @context.Item.TenantName + @context.Item.TenantId +
+
+
+ + +
+ @context.Item.AssignedTo +
+
+
+ + +
+ + @context.Item.Created.Date.ToString("d") + + + @context.Item.Created.Humanize() + +
+
+
+
+ + @ConstantString.NoRecords + + + @ConstantString.Loading + + + + +
+ +@code { + [CascadingParameter] private Task AuthState { get; set; } = default!; + [CascadingParameter] private UserProfile? UserProfile { get; set; } + + private bool _loading = false; + private int _defaultPageSize = 15; + private MudDataGrid _table = default!; + + private QaEscalationWithPaginiation.Query Query { get; set; } = new(); + private EnrolmentQueueEntryDto _currentDto = new(); + private HashSet _selectedItems = new(); + + private void ViewEnrolment(EnrolmentQueueEntryDto dto) + { + Navigation.NavigateTo($"/pages/qa/enrolments/escalation/{dto.Id}"); + } + + private void ViewParticipant(EnrolmentQueueEntryDto dto) + { + Navigation.NavigateTo($"/pages/participants/{dto.ParticipantId}"); + } + + private async Task> ServerReload(GridState state) + { + try + { + _loading = true; + Query.CurrentUser = UserProfile; + Query.OrderBy = state.SortDefinitions.FirstOrDefault()?.SortBy ?? "Created"; + Query.SortDirection = state.SortDefinitions.FirstOrDefault()?.Descending ?? true ? SortDirection.Descending.ToString() : SortDirection.Ascending.ToString(); + Query.PageNumber = state.Page + 1; + Query.PageSize = state.PageSize; + + var result = await GetNewMediator().Send(Query).ConfigureAwait(false); + return new GridData { TotalItems = result.TotalItems, Items = result.Items }; + } + finally + { + _loading = false; + } + } + + private async Task OnSearch(string text) + { + if (_loading) + { + return; + } + _selectedItems = new(); + Query.Keyword = text; + await _table.ReloadServerData(); + } + + private async Task OnRefresh() + { + _selectedItems = new (); + Query.Keyword = string.Empty; + await _table.ReloadServerData(); + } +} \ No newline at end of file diff --git a/src/Server.UI/Pages/QA/Enrolments/Components/QA1List.razor b/src/Server.UI/Pages/QA/Enrolments/Components/QA1List.razor index 18d3f338..6e8fd2c7 100644 --- a/src/Server.UI/Pages/QA/Enrolments/Components/QA1List.razor +++ b/src/Server.UI/Pages/QA/Enrolments/Components/QA1List.razor @@ -29,8 +29,8 @@
- - QA1 + + First Pass
@@ -62,8 +62,8 @@ Dense="true" EndIcon="@Icons.Material.Filled.KeyboardArrowDown" IconColor="Color.Info" AnchorOrigin="Origin.CenterLeft"> - - @ConstantString.View + + @ConstantString.View Participant @@ -160,6 +160,11 @@ _loading = false; } } + + private void ViewParticipant(EnrolmentQueueEntryDto dto) + { + Navigation.NavigateTo($"/pages/participants/{dto.ParticipantId}"); + } private async Task OnSearch(string text) { diff --git a/src/Server.UI/Pages/QA/Enrolments/Components/QA2List.razor b/src/Server.UI/Pages/QA/Enrolments/Components/QA2List.razor index c4f0ac6b..e81a7252 100644 --- a/src/Server.UI/Pages/QA/Enrolments/Components/QA2List.razor +++ b/src/Server.UI/Pages/QA/Enrolments/Components/QA2List.razor @@ -29,8 +29,8 @@
- - QA2 + + Second Pass
@@ -63,7 +63,7 @@ EndIcon="@Icons.Material.Filled.KeyboardArrowDown" IconColor="Color.Info" AnchorOrigin="Origin.CenterLeft"> - @ConstantString.View + @ConstantString.View Participant diff --git a/src/Server.UI/Pages/QA/Enrolments/Escalation.razor b/src/Server.UI/Pages/QA/Enrolments/Escalation.razor new file mode 100644 index 00000000..fd27eda2 --- /dev/null +++ b/src/Server.UI/Pages/QA/Enrolments/Escalation.razor @@ -0,0 +1,191 @@ +@page "/pages/qa/enrolments/escalation/{id:guid}" + +@attribute [Authorize(Policy = SecurityPolicies.SeniorInternal)] + +@using Cfo.Cats.Application.Common.Validators +@using Cfo.Cats.Application.Features.Participants.DTOs +@using Cfo.Cats.Application.Features.Participants.Queries +@using Cfo.Cats.Application.Features.QualityAssurance.Commands +@using Cfo.Cats.Application.Features.QualityAssurance.DTOs +@using Cfo.Cats.Application.Features.QualityAssurance.Queries +@using Cfo.Cats.Application.SecurityConstants +@using Cfo.Cats.Domain.Common.Enums +@using Cfo.Cats.Server.UI.Pages.QA.Enrolments.Components +@inherits CatsComponentBase + + + +@if (_participantDto is not null && _participantDto.EnrolmentStatus == EnrolmentStatus.SubmittedToAuthorityStatus) +{ + @if (_queueEntry!.IsAccepted || _queueEntry.IsCompleted) + { + + This entry has already been processed + + } + + + + + + + + + + + + + + + + + + + + + + + @if (_queueEntry.IsCompleted == false) + { + + + + + Accept + + + Return + + + Comment / Defer + + + + + + Characters: @CharacterCount / 1000 + + + Submit + + } + else + { + + This entry has already been processed + + } + + + + +} + +@code { + private MudForm? _form; + private EnrolmentQueueEntryDto? _queueEntry; + private ParticipantDto? _participantDto; + + [Parameter] public Guid Id { get; set; } + + [CascadingParameter] public UserProfile? UserProfile { get; set; } + + private SubmitEscalationResponse.Command Command { get; set; } = default!; + + protected override async Task OnInitializedAsync() + { + if (_participantDto is null) + { + var result = await GetNewMediator().Send(new GetEscalationEntryById.Query + { + Id = Id, + CurrentUser = UserProfile + }); + + if (result.Succeeded) + { + _queueEntry = result.Data!; + _participantDto = await GetNewMediator().Send(new GetParticipantById.Query + { + Id = _queueEntry.ParticipantId + }); + + Command = new SubmitEscalationResponse.Command + { + QueueEntryId = Id, + CurrentUser = UserProfile + }; + } + + StateHasChanged(); + } + } + + protected async Task SubmitToQa() + { + await _form!.Validate().ConfigureAwait(false); + if (_form.IsValid) + { + var result = await GetNewMediator().Send(Command); + + var message = Command.Response switch + { + SubmitEscalationResponse.EscalationResponse.Accept => "Participant accepted", + SubmitEscalationResponse.EscalationResponse.Return => "Participant returned to PQA", + _ => "Comment added" + }; + + + if (result.Succeeded) + { + Snackbar.Add(message, Severity.Info); + Navigation.NavigateTo("/pages/qa/servicedesk/enrolments"); + } + else + { + ShowActionFailure("Failed to return to submit", result); + } + } + } + + private void ShowActionFailure(string title, IResult result) + { + Snackbar.Add( + @
+

@title

+
    + @foreach (var e in result.Errors) + { +
  • @e
  • + } +
+
+ , Severity.Error, options => + { + options.RequireInteraction = true; + options.SnackbarVariant = Variant.Text; + }); + } + + private int CharacterCount => Command.Message?.Length ?? 0; + +} \ No newline at end of file diff --git a/src/Server.UI/Pages/QA/Enrolments/PQA.razor b/src/Server.UI/Pages/QA/Enrolments/PQA.razor index cc832af3..2c4b3c3a 100644 --- a/src/Server.UI/Pages/QA/Enrolments/PQA.razor +++ b/src/Server.UI/Pages/QA/Enrolments/PQA.razor @@ -1,7 +1,6 @@ @page "/pages/qa/enrolments/pqa/{id:guid}" @attribute [Authorize(Policy = SecurityPolicies.Pqa)] - @using Cfo.Cats.Application.Common.Validators @using Cfo.Cats.Application.Features.Participants.DTOs @using Cfo.Cats.Application.Features.Participants.Queries @@ -11,7 +10,6 @@ @using Cfo.Cats.Application.SecurityConstants @using Cfo.Cats.Domain.Common.Enums @using Cfo.Cats.Server.UI.Pages.QA.Enrolments.Components -@using Cfo.Cats.Server.UI.Pages.Participants.Components @inherits CatsComponentBase