diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index c9326dc2..f1ccfcaa 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -3,14 +3,14 @@ "isRoot": true, "tools": { "dotnet-ef": { - "version": "8.0.8", + "version": "8.0.10", "commands": [ "dotnet-ef" ], "rollForward": false }, "cake.tool": { - "version": "4.0.0", + "version": "4.2.0", "commands": [ "dotnet-cake" ], diff --git a/.gitignore b/.gitignore index 138ffa57..e2466a3b 100644 --- a/.gitignore +++ b/.gitignore @@ -471,3 +471,6 @@ Uploads/ Files/ /.vscode/settings.json +/playwright-report/ +/blob-report/ +/playwright/.cache/ diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..e9a8d744 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,91 @@ +{ + "name": "cfo-caseassessmenttrackingsystem", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "cfo-caseassessmenttrackingsystem", + "version": "1.0.0", + "license": "ISC", + "devDependencies": { + "@playwright/test": "^1.48.1", + "@types/node": "^22.7.6" + } + }, + "node_modules/@playwright/test": { + "version": "1.48.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.48.1.tgz", + "integrity": "sha512-s9RtWoxkOLmRJdw3oFvhFbs9OJS0BzrLUc8Hf6l2UdCNd1rqeEyD4BhCJkvzeEoD1FsK4mirsWwGerhVmYKtZg==", + "dev": true, + "dependencies": { + "playwright": "1.48.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@types/node": { + "version": "22.7.6", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.6.tgz", + "integrity": "sha512-/d7Rnj0/ExXDMcioS78/kf1lMzYk4BZV8MZGTBKzTGZ6/406ukkbYlIsZmMPhcR5KlkunDHQLrtAVmSq7r+mSw==", + "dev": true, + "dependencies": { + "undici-types": "~6.19.2" + } + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/playwright": { + "version": "1.48.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.48.1.tgz", + "integrity": "sha512-j8CiHW/V6HxmbntOfyB4+T/uk08tBy6ph0MpBXwuoofkSnLmlfdYNNkFTYD6ofzzlSqLA1fwH4vwvVFvJgLN0w==", + "dev": true, + "dependencies": { + "playwright-core": "1.48.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.48.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.48.1.tgz", + "integrity": "sha512-Yw/t4VAFX/bBr1OzwCuOMZkY1Cnb4z/doAFSwf4huqAGWmf9eMNjmK7NiOljCdLmxeRYcGPPmcDgU0zOlzP0YA==", + "dev": true, + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/undici-types": { + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", + "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", + "dev": true + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 00000000..7dc92f67 --- /dev/null +++ b/package.json @@ -0,0 +1,17 @@ +{ + "name": "cfo-caseassessmenttrackingsystem", + "version": "1.0.0", + "description": "[![.NET Core Unit Tests](https://github.com/ministryofjustice/CFO-CaseAssessmentTrackingSystem/actions/workflows/unittest.yml/badge.svg?branch=develop)](https://github.com/ministryofjustice/CFO-CaseAssessmentTrackingSystem/actions/workflows/unittest.yml)", + "main": "index.js", + "directories": { + "test": "test" + }, + "scripts": {}, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "@playwright/test": "^1.48.1", + "@types/node": "^22.7.6" + } +} diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 00000000..9cf2a702 --- /dev/null +++ b/playwright.config.ts @@ -0,0 +1,82 @@ +import { defineConfig, devices } from '@playwright/test'; + +/** + * Read environment variables from file. + * https://github.com/motdotla/dotenv + */ +// import dotenv from 'dotenv'; +// import path from 'path'; +// dotenv.config({ path: path.resolve(__dirname, '.env') }); + +/** + * See https://playwright.dev/docs/test-configuration. + */ +export default defineConfig({ + testDir: './test/playwright', + /* Run tests in files in parallel */ + fullyParallel: true, + /* Fail the build on CI if you accidentally left test.only in the source code. */ + forbidOnly: !!process.env.CI, + /* Retry on CI only */ + retries: process.env.CI ? 2 : 0, + /* Opt out of parallel tests on CI. */ + workers: process.env.CI ? 1 : undefined, + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ + reporter: 'html', + /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ + use: { + /* Base URL to use in actions like `await page.goto('/')`. */ + baseURL: 'https://localhost:7062/', + + /* Ignore self-signed SSL errors */ + ignoreHTTPSErrors: true, + + /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ + trace: 'on-first-retry', + }, + + /* Configure projects for major browsers */ + projects: [ + { + name: 'chromium', + use: { ...devices['Desktop Chrome'] }, + }, + + { + name: 'firefox', + use: { ...devices['Desktop Firefox'] }, + }, + + { + name: 'webkit', + use: { ...devices['Desktop Safari'] }, + }, + + /* Test against mobile viewports. */ + // { + // name: 'Mobile Chrome', + // use: { ...devices['Pixel 5'] }, + // }, + // { + // name: 'Mobile Safari', + // use: { ...devices['iPhone 12'] }, + // }, + + /* Test against branded browsers. */ + // { + // name: 'Microsoft Edge', + // use: { ...devices['Desktop Edge'], channel: 'msedge' }, + // }, + // { + // name: 'Google Chrome', + // use: { ...devices['Desktop Chrome'], channel: 'chrome' }, + // }, + ], + + /* Run your local dev server before starting the tests */ + // webServer: { + // command: 'npm run start', + // url: 'http://127.0.0.1:3000', + // reuseExistingServer: !process.env.CI, + // }, +}); diff --git a/src/Application/Common/Interfaces/IApplicationDbContext.cs b/src/Application/Common/Interfaces/IApplicationDbContext.cs index b311d70c..32eb7bb4 100644 --- a/src/Application/Common/Interfaces/IApplicationDbContext.cs +++ b/src/Application/Common/Interfaces/IApplicationDbContext.cs @@ -9,6 +9,7 @@ using Microsoft.EntityFrameworkCore.ChangeTracking; using Microsoft.EntityFrameworkCore.Infrastructure; using Cfo.Cats.Domain.Entities.Inductions; +using Cfo.Cats.Domain.Entities.Notifications; namespace Cfo.Cats.Application.Common.Interfaces; @@ -36,6 +37,8 @@ public interface IApplicationDbContext DbSet ParticipantAssessments { get; } DbSet ParticipantBios { get; } DbSet ParticipantEnrolmentHistories { get; } + DbSet ParticipantLocationHistories { get; } + DbSet ParticipantOwnershipHistories { get; } DbSet Timelines { get; } @@ -61,6 +64,6 @@ public interface IApplicationDbContext DbSet HubInductions { get; } DbSet WingInductions { get; } - + DbSet Notifications { get; } } diff --git a/src/Application/Features/Dashboard/DTOs/ParticipantCountSummaryDto.cs b/src/Application/Features/Dashboard/DTOs/ParticipantCountSummaryDto.cs new file mode 100644 index 00000000..bbdb16fc --- /dev/null +++ b/src/Application/Features/Dashboard/DTOs/ParticipantCountSummaryDto.cs @@ -0,0 +1,11 @@ +namespace Cfo.Cats.Application.Features.Dashboard.DTOs; + +public class ParticipantCountSummaryDto +{ + public int IdentifiedCases { get; set; } + public int EnrollingCases { get; set; } + public int CasesAtPqa { get; set; } + public int CasesAtCfo { get; set; } + public int ApprovedCases { get; set; } +} + diff --git a/src/Application/Features/Dashboard/Queries/GetDashboard.cs b/src/Application/Features/Dashboard/Queries/GetMyParticipantsDashboard.cs similarity index 71% rename from src/Application/Features/Dashboard/Queries/GetDashboard.cs rename to src/Application/Features/Dashboard/Queries/GetMyParticipantsDashboard.cs index fd15d46f..99d60d16 100644 --- a/src/Application/Features/Dashboard/Queries/GetDashboard.cs +++ b/src/Application/Features/Dashboard/Queries/GetMyParticipantsDashboard.cs @@ -1,24 +1,27 @@ using System.Reflection.Emit; using Cfo.Cats.Application.Common.Security; +using Cfo.Cats.Application.Features.Dashboard.DTOs; using Cfo.Cats.Application.SecurityConstants; using DocumentFormat.OpenXml.Math; namespace Cfo.Cats.Application.Features.Dashboard.Queries; -public static class GetDashboard +public static class GetMyParticipantsDashboard { [RequestAuthorize(Policy = SecurityPolicies.AuthorizedUser)] - public class Query : IRequest> + public class Query : IRequest> { public UserProfile? CurrentUser { get; set; } } - public class Handler(IUnitOfWork unitOfWork) : IRequestHandler> + public class Handler(IUnitOfWork unitOfWork) : IRequestHandler> { - public async Task> Handle(Query request, CancellationToken cancellationToken) + public async Task> Handle(Query request, CancellationToken cancellationToken) { - var query = from p in unitOfWork.DbContext.Participants.AsNoTracking() - where p.OwnerId == request.CurrentUser!.UserId + var query = from p in unitOfWork.DbContext + .Participants.AsNoTracking() + where + p.OwnerId == request.CurrentUser!.UserId group p by p.EnrolmentStatus into grp select new @@ -29,7 +32,7 @@ into grp var results = await query.ToArrayAsync(cancellationToken); - DashboardDto dto = new DashboardDto(); + ParticipantCountSummaryDto dto = new ParticipantCountSummaryDto(); foreach (var result in results) { if (result.Status == EnrolmentStatus.ApprovedStatus) @@ -58,7 +61,7 @@ into grp } } - return Result.Success(dto); + return Result.Success(dto); } } @@ -72,14 +75,4 @@ public Validator() } } -} - -public class DashboardDto -{ - public int IdentifiedCases { get; set; } - public int EnrollingCases { get; set; } - public int CasesAtPqa { get; set; } - public int CasesAtCfo { get; set; } - public int ApprovedCases { get; set; } - public int UnreadNotifications { get; set; } -} +} \ No newline at end of file diff --git a/src/Application/Features/Dashboard/Queries/GetMyTeamsParticipantsDashboard.cs b/src/Application/Features/Dashboard/Queries/GetMyTeamsParticipantsDashboard.cs new file mode 100644 index 00000000..edf47ed0 --- /dev/null +++ b/src/Application/Features/Dashboard/Queries/GetMyTeamsParticipantsDashboard.cs @@ -0,0 +1,83 @@ +using System.Reflection.Emit; +using Cfo.Cats.Application.Common.Security; +using Cfo.Cats.Application.Features.Dashboard.DTOs; +using Cfo.Cats.Application.SecurityConstants; +using DocumentFormat.OpenXml.Math; + +namespace Cfo.Cats.Application.Features.Dashboard.Queries; + +public static class GetMyTeamsParticipantsDashboard +{ + [RequestAuthorize(Policy = SecurityPolicies.AuthorizedUser)] + public class Query : IRequest> + { + public UserProfile? CurrentUser { get; set; } + public string? TenantId { get; set; } + } + + public class Handler(IUnitOfWork unitOfWork) : IRequestHandler> + { + public async Task> Handle(Query request, CancellationToken cancellationToken) + { + var query = from p in unitOfWork.DbContext + .Participants.AsNoTracking() + where + p.Owner!.TenantId!.StartsWith(request.CurrentUser!.TenantId!) + group p by p.EnrolmentStatus + into grp + select new + { + Status = grp.Key, + Count = grp.Count() + }; + + var results = await query.ToArrayAsync(cancellationToken); + + var dto = new ParticipantCountSummaryDto(); + foreach (var result in results) + { + if (result.Status == EnrolmentStatus.ApprovedStatus) + { + dto.ApprovedCases = result.Count; + continue; + } + if (result.Status == EnrolmentStatus.IdentifiedStatus) + { + dto.IdentifiedCases = result.Count; + continue; + } + if(result.Status == EnrolmentStatus.EnrollingStatus) + { + dto.EnrollingCases = result.Count; + continue; + } + if (result.Status == EnrolmentStatus.SubmittedToProviderStatus) + { + dto.CasesAtPqa = result.Count; + continue; + } + if (result.Status == EnrolmentStatus.SubmittedToAuthorityStatus) + { + dto.CasesAtCfo = result.Count; + } + } + + return Result.Success(dto); + + } + } + + public class Validator : AbstractValidator + { + public Validator() + { + RuleFor(q => q.CurrentUser) + .NotNull(); + + RuleFor(q => q.CurrentUser!.AssignedRoles) + .NotEmpty(); + + } + } + +} \ No newline at end of file diff --git a/src/Application/Features/Notifications/Command/MarkAsRead.cs b/src/Application/Features/Notifications/Command/MarkAsRead.cs new file mode 100644 index 00000000..477c50cb --- /dev/null +++ b/src/Application/Features/Notifications/Command/MarkAsRead.cs @@ -0,0 +1,75 @@ +using Cfo.Cats.Application.Common.Security; +using Cfo.Cats.Application.Common.Validators; +using Cfo.Cats.Application.SecurityConstants; + +namespace Cfo.Cats.Application.Features.Notifications.Command +{ + public static class MarkAsRead + { + [RequestAuthorize(Policy = SecurityPolicies.Enrol)] + public class Command : IRequest> + { + public Guid[] NotificationsToMarkAsRead { get; set; } = []; + public UserProfile? CurrentUser { get; set; } + } + + public class Handler(IUnitOfWork unitOfWork) : IRequestHandler> + { + public async Task> Handle(Command request, CancellationToken cancellationToken) + { + foreach (var notificationId in request.NotificationsToMarkAsRead) + { + var notification = await unitOfWork.DbContext.Notifications + .FirstOrDefaultAsync(x => x.Id == notificationId); + + if (notification is null) + { + return Result.Failure("Notification not found"); + } + else if (notification.ReadDate.HasValue == false) + { + notification.UpdateReadDate(DateTime.UtcNow); + } + + } + + return Result.Success(true); + } + } + + public class A_ : AbstractValidator + { + public A_() + { + RuleFor(x => x.NotificationsToMarkAsRead) + .NotEmpty(); + + RuleFor(x => x.CurrentUser) + .NotNull(); + } + } + + public class A_NotificationsExists : AbstractValidator + { + private readonly IUnitOfWork _unitOfWork; + + public A_NotificationsExists(IUnitOfWork unitOfWork) + { + _unitOfWork = unitOfWork; + + // Validate each NotificationId in the list + RuleForEach(p => p.NotificationsToMarkAsRead) + .NotEmpty() + .WithMessage(string.Format(ValidationConstants.GuidMessage, "Notification")) + .MustAsync(Exist) + .WithMessage("Notification does not exist"); + + } + + // Check if the participant exists in the database + private async Task Exist(Guid notificationId, CancellationToken cancellationToken) + => await _unitOfWork.DbContext.Notifications.AnyAsync(p => p.Id == notificationId, cancellationToken); + } + + } +} \ No newline at end of file diff --git a/src/Application/Features/Notifications/Command/MarkAsUnread.cs b/src/Application/Features/Notifications/Command/MarkAsUnread.cs new file mode 100644 index 00000000..e6a3d82f --- /dev/null +++ b/src/Application/Features/Notifications/Command/MarkAsUnread.cs @@ -0,0 +1,75 @@ +using Cfo.Cats.Application.Common.Security; +using Cfo.Cats.Application.Common.Validators; +using Cfo.Cats.Application.SecurityConstants; + +namespace Cfo.Cats.Application.Features.Notifications.Command +{ + public static class MarkAsUnread + { + [RequestAuthorize(Policy = SecurityPolicies.Enrol)] + public class Command : IRequest> + { + public Guid[] NotificationsToMarkAsUnread { get; set; } = []; + public UserProfile? CurrentUser { get; set; } + } + + public class Handler(IUnitOfWork unitOfWork) : IRequestHandler> + { + public async Task> Handle(Command request, CancellationToken cancellationToken) + { + foreach (var notificationId in request.NotificationsToMarkAsUnread) + { + var notification = await unitOfWork.DbContext.Notifications + .FirstOrDefaultAsync(x => x.Id == notificationId); + + if (notification is null) + { + return Result.Failure("Notification not found"); + } + else if (notification.ReadDate.HasValue) + { + notification.UpdateReadDate(null); + } + + } + + return Result.Success(true); + } + } + + public class A_ : AbstractValidator + { + public A_() + { + RuleFor(x => x.NotificationsToMarkAsUnread) + .NotEmpty(); + + RuleFor(x => x.CurrentUser) + .NotNull(); + } + } + + public class A_NotificationsExists : AbstractValidator + { + private readonly IUnitOfWork _unitOfWork; + + public A_NotificationsExists(IUnitOfWork unitOfWork) + { + _unitOfWork = unitOfWork; + + // Validate each NotificationId in the list + RuleForEach(p => p.NotificationsToMarkAsUnread) + .NotEmpty() + .WithMessage(string.Format(ValidationConstants.GuidMessage, "Notification")) + .MustAsync(Exist) + .WithMessage("Notification does not exist"); + + } + + // Check if the participant exists in the database + private async Task Exist(Guid notificationId, CancellationToken cancellationToken) + => await _unitOfWork.DbContext.Notifications.AnyAsync(p => p.Id == notificationId, cancellationToken); + } + + } +} \ No newline at end of file diff --git a/src/Application/Features/Notifications/DTOs/NotificationDto.cs b/src/Application/Features/Notifications/DTOs/NotificationDto.cs new file mode 100644 index 00000000..da693ae0 --- /dev/null +++ b/src/Application/Features/Notifications/DTOs/NotificationDto.cs @@ -0,0 +1,31 @@ +using Cfo.Cats.Application.Features.Identity.DTOs; +using Cfo.Cats.Domain.Entities.Notifications; +using DocumentFormat.OpenXml.Drawing.Charts; + +namespace Cfo.Cats.Application.Features.Notifications.DTOs; + +public class NotificationDto +{ + public Guid Id { get; set; } + public string Heading { get; set; } = default!; + public string Details { get; set; } = default!; + + public DateTime NotificationDate { get; set; } + public DateTime? ReadDate { get; set; } + public string? Link { get;set; } + + private class Mapper : Profile + { + public Mapper() + { + CreateMap(MemberList.Destination) + .ForMember(t => t.Id, opt => opt.MapFrom(src => src.Id)) + .ForMember(t => t.Heading, opt => opt.MapFrom(src => src.Heading)) + .ForMember(t => t.Details, opt => opt.MapFrom(src => src.Details)) + .ForMember(t => t.NotificationDate, opt => opt.MapFrom(src => src.NotificationDate)) + .ForMember(t => t.ReadDate, opt => opt.MapFrom(src => src.ReadDate)) + .ForMember(t => t.Link, opt => opt.MapFrom(src => src.Link)); + } + } + +} \ No newline at end of file diff --git a/src/Application/Features/Notifications/EventHandlers/NotifyOwnerParticipantHasBeenApproved.cs b/src/Application/Features/Notifications/EventHandlers/NotifyOwnerParticipantHasBeenApproved.cs new file mode 100644 index 00000000..f272ef89 --- /dev/null +++ b/src/Application/Features/Notifications/EventHandlers/NotifyOwnerParticipantHasBeenApproved.cs @@ -0,0 +1,33 @@ +using Cfo.Cats.Domain.Entities.Notifications; +using Cfo.Cats.Domain.Events; + +namespace Cfo.Cats.Application.Features.Notifications.EventHandlers; + +public class NotifyOwnerParticipantHasBeenApproved(IUnitOfWork unitOfWork) : INotificationHandler +{ + public async Task Handle(ParticipantTransitionedDomainEvent notification, CancellationToken cancellationToken) + { + if (notification.To == EnrolmentStatus.ApprovedStatus) + { + const string heading = "Enrolment approved"; + + string details = "You have enrolments that have been approved"; + + Notification? previous = unitOfWork.DbContext.Notifications.FirstOrDefault( + n => n.Heading == heading + && n.OwnerId == notification.Item.OwnerId + && n.ReadDate == null + ); + + previous?.ResetNotificationDate(); + + if (previous is null) + { + var n = Notification.Create(heading, details, notification.Item.OwnerId!); + n.SetLink($"/pages/participants/?listView=Approved"); + await unitOfWork.DbContext.Notifications.AddAsync(n, cancellationToken); + } + + } + } +} \ No newline at end of file diff --git a/src/Application/Features/Notifications/EventHandlers/NotifyOwnerParticipantHasBeenReturnedEventHandler.cs b/src/Application/Features/Notifications/EventHandlers/NotifyOwnerParticipantHasBeenReturnedEventHandler.cs new file mode 100644 index 00000000..2a5e1eed --- /dev/null +++ b/src/Application/Features/Notifications/EventHandlers/NotifyOwnerParticipantHasBeenReturnedEventHandler.cs @@ -0,0 +1,35 @@ +using Cfo.Cats.Domain.Entities.Notifications; +using Cfo.Cats.Domain.Events; + +namespace Cfo.Cats.Application.Features.Notifications.EventHandlers; + +public class NotifyOwnerParticipantHasBeenReturnedEventHandler(IUnitOfWork unitOfWork) : INotificationHandler +{ + public async Task Handle(ParticipantTransitionedDomainEvent notification, CancellationToken cancellationToken) + { + if (notification.From == EnrolmentStatus.SubmittedToProviderStatus && notification.To == EnrolmentStatus.EnrollingStatus) + { + const string heading = "Enrolment returned"; + + string details = "You have enrolments that have been returned by PQA"; + + Notification? previous = unitOfWork.DbContext.Notifications.FirstOrDefault( + n => n.Heading == heading + && n.OwnerId == notification.Item.OwnerId + && n.ReadDate == null + ); + + previous?.ResetNotificationDate(); + + if(previous is null) + { + var n = Notification.Create(heading, details, notification.Item.OwnerId!); + n.SetLink($"/pages/participants/?listView=Enrolling"); + await unitOfWork.DbContext.Notifications.AddAsync(n, cancellationToken); + } + } + } +} + + + diff --git a/src/Application/Features/Notifications/EventHandlers/NotifyPqaEnrolmentRejectedEventHandler.cs b/src/Application/Features/Notifications/EventHandlers/NotifyPqaEnrolmentRejectedEventHandler.cs new file mode 100644 index 00000000..ad0b7138 --- /dev/null +++ b/src/Application/Features/Notifications/EventHandlers/NotifyPqaEnrolmentRejectedEventHandler.cs @@ -0,0 +1,40 @@ +using Cfo.Cats.Domain.Entities.Notifications; +using Cfo.Cats.Domain.Events; + +namespace Cfo.Cats.Application.Features.Notifications.EventHandlers; + +public class NotifyPqaEnrolmentRejectedEventHandler(IUnitOfWork unitOfWork) : INotificationHandler +{ + public async Task Handle(ParticipantTransitionedDomainEvent notification, CancellationToken cancellationToken) + { + + if (notification.From == EnrolmentStatus.SubmittedToAuthorityStatus && notification.To == EnrolmentStatus.SubmittedToProviderStatus) + { + const string heading = "Enrolment returned from authority"; + string details = "You have enrolments that have been returned"; + + // who did the PQA? + var qaUser = await unitOfWork.DbContext + .EnrolmentPqaQueue.AsNoTracking() + .Where(pqa => + pqa.ParticipantId == notification.Item.Id && pqa.IsAccepted == true && pqa.IsCompleted == true) + .Select(pqa => pqa.LastModifiedBy!) + .FirstOrDefaultAsync(cancellationToken); + + Notification? previous = unitOfWork.DbContext.Notifications.FirstOrDefault( + n => n.Heading == heading + && n.OwnerId == qaUser + && n.ReadDate == null + ); + + previous?.ResetNotificationDate(); + + if (previous == null) + { + var n = Notification.Create(heading, details, qaUser!); + n.SetLink($"pages/qa/enrolments/pqa/"); + await unitOfWork.DbContext.Notifications.AddAsync(n, cancellationToken); + } + } + } +} \ No newline at end of file diff --git a/src/Application/Features/Notifications/Queries/NotificationsWithPaginationQuery.cs b/src/Application/Features/Notifications/Queries/NotificationsWithPaginationQuery.cs new file mode 100644 index 00000000..6fd05df1 --- /dev/null +++ b/src/Application/Features/Notifications/Queries/NotificationsWithPaginationQuery.cs @@ -0,0 +1,29 @@ +using Cfo.Cats.Application.Common.Security; +using Cfo.Cats.Application.Features.Notifications.DTOs; +using Cfo.Cats.Application.Features.Notifications.Specifications; +using Cfo.Cats.Application.SecurityConstants; +using Cfo.Cats.Domain.Entities.Notifications; + +namespace Cfo.Cats.Application.Features.Notifications.Queries; + +public static class NotificationsWithPaginationQuery +{ + [RequestAuthorize(Policy = SecurityPolicies.AuthorizedUser)] + public class Query : NotificationsAdvancedFilter, IRequest> + { + public NotificationAdvancedSpecification Specification => new(this); + } + + public class Handler(IUnitOfWork unitOfWork, IMapper mapper) + : IRequestHandler> + { + public async Task> Handle(Query request, CancellationToken cancellationToken) + { + var data = await unitOfWork.DbContext.Notifications.OrderBy($"{request.OrderBy} {request.SortDirection}") + .ProjectToPaginatedDataAsync(request.Specification, request.PageNumber, request.PageSize, mapper.ConfigurationProvider, cancellationToken); + + return data; + + } + } +} \ No newline at end of file diff --git a/src/Application/Features/Notifications/Specifications/NotificationAdvancedSpecification.cs b/src/Application/Features/Notifications/Specifications/NotificationAdvancedSpecification.cs new file mode 100644 index 00000000..6b40669b --- /dev/null +++ b/src/Application/Features/Notifications/Specifications/NotificationAdvancedSpecification.cs @@ -0,0 +1,12 @@ +using Cfo.Cats.Domain.Entities.Notifications; + +namespace Cfo.Cats.Application.Features.Notifications.Specifications; + +public sealed class NotificationAdvancedSpecification : Specification +{ + public NotificationAdvancedSpecification(NotificationsAdvancedFilter filter) + { + Query.Where(r => r.ReadDate == null, filter.ShowReadNotifications == false) + .Where(n => n.OwnerId == filter.CurrentUser!.UserId); + } +} \ No newline at end of file diff --git a/src/Application/Features/Notifications/Specifications/NotificationsAdvancedFilter.cs b/src/Application/Features/Notifications/Specifications/NotificationsAdvancedFilter.cs new file mode 100644 index 00000000..833b995d --- /dev/null +++ b/src/Application/Features/Notifications/Specifications/NotificationsAdvancedFilter.cs @@ -0,0 +1,18 @@ +using Cfo.Cats.Application.Common.Security; + +namespace Cfo.Cats.Application.Features.Notifications.Specifications; + +public class NotificationsAdvancedFilter : PaginationFilter +{ + public UserProfile? CurrentUser { get; set; } + + public bool ShowReadNotifications { get; set; } = false; + + public NotificationsListView ListView { get; set; } = NotificationsListView.Default; + +} + +public enum NotificationsListView +{ + [Description("Default")] Default = 0, +} \ No newline at end of file diff --git a/src/Application/Features/Participants/EventHandlers/ParticipantAssigned.cs b/src/Application/Features/Participants/EventHandlers/ParticipantAssigned.cs new file mode 100644 index 00000000..d8d32a9a --- /dev/null +++ b/src/Application/Features/Participants/EventHandlers/ParticipantAssigned.cs @@ -0,0 +1,26 @@ +using Cfo.Cats.Domain.Entities.Participants; +using Cfo.Cats.Domain.Events; + +namespace Cfo.Cats.Application.Features.Participants.EventHandlers; + +public class ParticipantAssigned(IUnitOfWork unitOfWork) : INotificationHandler +{ + public async Task Handle(ParticipantAssignedDomainEvent notification, CancellationToken cancellationToken) + { + var owner = await unitOfWork.DbContext.Users.FindAsync(notification.NewOwner); + + if(owner is null) + { + return; + } + + var history = ParticipantOwnershipHistory.Create( + notification.Item.Id, + owner.Id, + owner.TenantId!, + DateTime.UtcNow); + + await unitOfWork.DbContext.ParticipantOwnershipHistories.AddAsync(history, cancellationToken); + } + +} diff --git a/src/Application/Features/Participants/EventHandlers/ParticipantCreated.cs b/src/Application/Features/Participants/EventHandlers/ParticipantCreated.cs index 4bef9f49..e1c81943 100644 --- a/src/Application/Features/Participants/EventHandlers/ParticipantCreated.cs +++ b/src/Application/Features/Participants/EventHandlers/ParticipantCreated.cs @@ -7,7 +7,12 @@ public class ParticipantCreated(IUnitOfWork unitOfWork) : INotificationHandler

+{ + public async Task Handle(ParticipantMovedDomainEvent notification, CancellationToken cancellationToken) + { + var history = ParticipantLocationHistory.Create( + notification.Item.Id, + notification.To.Id, + DateTime.UtcNow); + + await unitOfWork.DbContext.ParticipantLocationHistories.AddAsync(history, cancellationToken); + } +} diff --git a/src/Application/Features/QualityAssurance/Commands/ArchiveCase.cs b/src/Application/Features/QualityAssurance/Commands/ArchiveCase.cs index 5daf7452..074f8832 100644 --- a/src/Application/Features/QualityAssurance/Commands/ArchiveCase.cs +++ b/src/Application/Features/QualityAssurance/Commands/ArchiveCase.cs @@ -1,4 +1,5 @@ using Cfo.Cats.Application.Common.Security; +using Cfo.Cats.Application.Common.Validators; using Cfo.Cats.Application.SecurityConstants; namespace Cfo.Cats.Application.Features.QualityAssurance.Commands; @@ -9,7 +10,8 @@ public static class ArchiveCase public class Command : IRequest { public required string ParticipantId { get; set; } - + [Description("Reason for Archive")] public ArchiveReason ArchiveReason { get; set; } = ArchiveReason.CaseloadTooHigh; + [Description("Justification for Archive")] public string? Justification { get; set; } } public class Handler(IUnitOfWork unitOfWork) : IRequestHandler @@ -17,13 +19,15 @@ public class Handler(IUnitOfWork unitOfWork) : IRequestHandler public async Task Handle(Command request, CancellationToken cancellationToken) { var participant = await unitOfWork.DbContext.Participants.FindAsync(request.ParticipantId); + participant!.Archive(request.ArchiveReason,request.Justification); participant!.TransitionTo(EnrolmentStatus.ArchivedStatus); + // ReSharper disable once MethodHasAsyncOverload return Result.Success(); } } - public class A_ParticipantMustExistValidator : AbstractValidator + public class A_ParticipantMustExistValidator : AbstractValidator { private readonly IUnitOfWork _unitOfWork; public A_ParticipantMustExistValidator(IUnitOfWork unitOfWork) @@ -41,6 +45,17 @@ public A_ParticipantMustExistValidator(IUnitOfWork unitOfWork) private async Task MustExist(string identifier, CancellationToken cancellationToken) => await _unitOfWork.DbContext.Participants.AnyAsync(e => e.Id == identifier, cancellationToken); } - - + + public class Validator : AbstractValidator + { + public Validator() + { + RuleFor(c => c.Justification) + .NotEmpty() + .When(c => c.ArchiveReason.RequiresJustification) + .WithMessage("You must provide a justification for the selected Archive reason") + .Matches(ValidationConstants.Notes) + .WithMessage(string.Format(ValidationConstants.NotesMessage, "Justification")); + } + } } diff --git a/src/Application/SecurityConstants/RoleNames.cs b/src/Application/SecurityConstants/RoleNames.cs index e4af6437..fa69a28f 100644 --- a/src/Application/SecurityConstants/RoleNames.cs +++ b/src/Application/SecurityConstants/RoleNames.cs @@ -2,19 +2,11 @@ public static class RoleNames { - ///

- /// A provider role, perform QA and finance services for a provider - /// public const string QAFinance = "QA + Finance"; - - /// - /// A CFO QA Officer - /// public const string QAOfficer = "CFO QA Officer"; - - public const string QASupportManager = "CFO QA Support Manager"; public const string QAManager = "CFO QA Manager"; + public const string PerformanceManager = "Performance Manager"; public const string SMT = "SMT"; public const string SystemSupport = "System Support"; } diff --git a/src/Domain/Common/Enums/ArchiveReason.cs b/src/Domain/Common/Enums/ArchiveReason.cs new file mode 100644 index 00000000..7c60f79a --- /dev/null +++ b/src/Domain/Common/Enums/ArchiveReason.cs @@ -0,0 +1,26 @@ +using Ardalis.SmartEnum; + +namespace Cfo.Cats.Domain.Common.Enums; + +public sealed class ArchiveReason : SmartEnum +{ + public static readonly ArchiveReason CaseloadTooHigh = new("Caseload for this location is too high", 0, false); + public static readonly ArchiveReason Deceased = new("Deceased", 1, false); + public static readonly ArchiveReason LicenceEnd = new("Licence end date reached", 2, false); + public static readonly ArchiveReason MovedOutsideProviderArea = new("Moved outside of provider delivery catchment area", 3, false); + public static readonly ArchiveReason MovedToNonCFO = new("Moved to non-CFO location", 4, false); + public static readonly ArchiveReason NoFurtherSupport = new("No further support required", 5, false); + public static readonly ArchiveReason NoRightToLiveWork = new("No supporting right to live / work documentation", 6, false); + public static readonly ArchiveReason NoWishToParticipate = new("Participant has stated they do not wish to participate", 7, false); + public static readonly ArchiveReason NoLongerEngaging = new("Participant is no longer engaging with provision", 8, false); + public static readonly ArchiveReason PersonalCircumstances = new("Personal circumstances", 9, false); + public static readonly ArchiveReason Other = new("Other", 10, true); + + public bool RequiresJustification { get; } + + private ArchiveReason(string name, int value, bool requiresJustification) + : base(name, value) + { + RequiresJustification = requiresJustification; + } +} \ No newline at end of file diff --git a/src/Domain/Common/Enums/EnrolmentStatus.cs b/src/Domain/Common/Enums/EnrolmentStatus.cs index 754a25de..7549cf5c 100644 --- a/src/Domain/Common/Enums/EnrolmentStatus.cs +++ b/src/Domain/Common/Enums/EnrolmentStatus.cs @@ -36,7 +36,7 @@ public bool AllowSuspend() => CanTransitionTo(DormantStatus); public bool AllowSubmitToPqa() => - CanTransitionTo(SubmittedToProviderStatus); + this == EnrollingStatus; public virtual bool AllowEnrolmentLocationChange() => false; diff --git a/src/Domain/Entities/Notifications/Notification.cs b/src/Domain/Entities/Notifications/Notification.cs new file mode 100644 index 00000000..0c0f7a90 --- /dev/null +++ b/src/Domain/Entities/Notifications/Notification.cs @@ -0,0 +1,54 @@ +using Cfo.Cats.Domain.Common.Entities; +using Cfo.Cats.Domain.Events; + +namespace Cfo.Cats.Domain.Entities.Notifications; + +public class Notification : OwnerPropertyEntity +{ + #pragma warning disable CS8618 + private Notification() + { + } + #pragma warning restore CS8618 + + private Notification(string heading, string details, string userId) + { + Id = Guid.NewGuid(); + Heading = heading; + Details = details; + OwnerId = userId; + NotificationDate = DateTime.UtcNow; + + AddDomainEvent(new NotificationCreatedDomainEvent(this)); + } + + public static Notification Create(string heading, string details, string userId) + { + return new Notification(heading, details, userId); + } + + public Notification SetLink(string url) + { + Link = url; + return this; + } + public Notification UpdateReadDate(DateTime? readDate) + { + ReadDate = readDate; + return this; + } + + public Notification ResetNotificationDate() + { + NotificationDate = DateTime.UtcNow; + return this; + } + + public string Heading { get; private set; } + public string Details { get; private set; } + + public string? Link {get; private set; } + + public DateTime NotificationDate {get; private set;} + public DateTime? ReadDate { get; private set; } +} \ No newline at end of file diff --git a/src/Domain/Entities/Participants/Participant.cs b/src/Domain/Entities/Participants/Participant.cs index fe957fe3..08994147 100644 --- a/src/Domain/Entities/Participants/Participant.cs +++ b/src/Domain/Entities/Participants/Participant.cs @@ -54,7 +54,7 @@ public static Participant CreateFrom( Nationality = nationality }; - p.AddDomainEvent(new ParticipantCreatedDomainEvent(p)); + p.AddDomainEvent(new ParticipantCreatedDomainEvent(p, locationId)); return p; } @@ -91,6 +91,13 @@ public static Participant CreateFrom( /// public string? EnrolmentLocationJustification { get; private set; } + /// + /// The justifcation for Archiving participant + /// + public string? ArchiveJustification { get; private set; } + + public ArchiveReason? ArchiveReason{ get; private set; } + public string? AssessmentJustification { get; private set; } public string? RegistrationDetailsJson { get; private set; } @@ -319,4 +326,18 @@ public Participant SetRiskDue(DateTime riskDueDate) RiskDue = riskDueDate; return this; } + + /// + /// Archives the participant + /// + /// + /// + /// + public Participant Archive(ArchiveReason archiveReason, string? justificationReason) + { + ArchiveJustification = justificationReason; + ArchiveReason = archiveReason; + + return this; + } } \ No newline at end of file diff --git a/src/Domain/Entities/Participants/ParticipantLocationHistory.cs b/src/Domain/Entities/Participants/ParticipantLocationHistory.cs new file mode 100644 index 00000000..f2313971 --- /dev/null +++ b/src/Domain/Entities/Participants/ParticipantLocationHistory.cs @@ -0,0 +1,25 @@ +using Cfo.Cats.Domain.Common.Entities; + +namespace Cfo.Cats.Domain.Entities.Participants; + +public class ParticipantLocationHistory : BaseAuditableEntity +{ +#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + private ParticipantLocationHistory() + { + } +#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + + private ParticipantLocationHistory(string participantId, int locationId, DateTime from) + { + ParticipantId = participantId; + LocationId = locationId; + From = from; + } + + public static ParticipantLocationHistory Create(string participantId, int locationId, DateTime from) => new(participantId, locationId, from); + + public string ParticipantId { get; private set; } + public int LocationId { get; private set; } + public DateTime From { get; private set; } +} diff --git a/src/Domain/Entities/Participants/ParticipantOwnershipHistory.cs b/src/Domain/Entities/Participants/ParticipantOwnershipHistory.cs new file mode 100644 index 00000000..21255b21 --- /dev/null +++ b/src/Domain/Entities/Participants/ParticipantOwnershipHistory.cs @@ -0,0 +1,27 @@ +using Cfo.Cats.Domain.Common.Entities; + +namespace Cfo.Cats.Domain.Entities.Participants; + +public class ParticipantOwnershipHistory : BaseAuditableEntity +{ +#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + private ParticipantOwnershipHistory() + { + } +#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + + private ParticipantOwnershipHistory(string participantId, string ownerId, string tenantId, DateTime from) + { + ParticipantId = participantId; + TenantId = tenantId; + OwnerId = ownerId; + From = from; + } + + public static ParticipantOwnershipHistory Create(string participantId, string ownerId, string tenantId, DateTime from) => new(participantId, ownerId, tenantId, from); + + public string TenantId { get; private set; } + public string ParticipantId { get; private set; } + public string OwnerId { get; private set; } + public DateTime From { get; private set; } +} diff --git a/src/Domain/Events/NotificationEvents.cs b/src/Domain/Events/NotificationEvents.cs new file mode 100644 index 00000000..fec575b7 --- /dev/null +++ b/src/Domain/Events/NotificationEvents.cs @@ -0,0 +1,8 @@ +using Cfo.Cats.Domain.Entities.Notifications; + +namespace Cfo.Cats.Domain.Events; + +public sealed class NotificationCreatedDomainEvent(Notification notification) : DomainEvent +{ + public Notification Item {get;} = notification; +} \ No newline at end of file diff --git a/src/Domain/Events/ParticipantEvents.cs b/src/Domain/Events/ParticipantEvents.cs index a8d4ca53..9367dcf5 100644 --- a/src/Domain/Events/ParticipantEvents.cs +++ b/src/Domain/Events/ParticipantEvents.cs @@ -4,9 +4,10 @@ namespace Cfo.Cats.Domain.Events; -public sealed class ParticipantCreatedDomainEvent(Participant participant) : DomainEvent +public sealed class ParticipantCreatedDomainEvent(Participant participant, int locationId) : DomainEvent { public Participant Item { get; } = participant; + public int LocationId { get; } = locationId; } public sealed class ParticipantAssignedDomainEvent(Participant participant, string? from, string? to) : DomainEvent diff --git a/src/Infrastructure/Constants/ConstantString.cs b/src/Infrastructure/Constants/ConstantString.cs index 724734b8..ce32184c 100644 --- a/src/Infrastructure/Constants/ConstantString.cs +++ b/src/Infrastructure/Constants/ConstantString.cs @@ -1,5 +1,6 @@ using System.Globalization; using System.Resources; +using System.Threading; namespace Cfo.Cats.Infrastructure.Constants; @@ -131,4 +132,12 @@ public static string Localize(string key) public static string Reassign => Localize("Reassign"); + public static string MarkAsRead => + Localize("Mark As Read"); + public static string MarkAsUnread => + Localize("Mark As Unread"); + public static string ShowReadNotification => + Localize("Show Read Notification"); + public static string ShowUnreadNotification => + Localize("Show Unread Notification"); } \ No newline at end of file diff --git a/src/Infrastructure/Constants/Database/DatabaseConstants.cs b/src/Infrastructure/Constants/Database/DatabaseConstants.cs index 75160713..70aa209a 100644 --- a/src/Infrastructure/Constants/Database/DatabaseConstants.cs +++ b/src/Infrastructure/Constants/Database/DatabaseConstants.cs @@ -1,4 +1,4 @@ -using Microsoft.EntityFrameworkCore.Metadata.Builders; +using Microsoft.EntityFrameworkCore.Metadata.Builders; namespace Cfo.Cats.Infrastructure.Constants.Database; @@ -38,6 +38,8 @@ public static class Tables public const string PathwayPlan = nameof(PathwayPlan); public const string PathwayPlanReviewHistory = nameof(PathwayPlanReviewHistory); public const string Supervisor = nameof(Supervisor); + public const string LocationHistory = nameof(LocationHistory); + public const string OwnershipHistory = nameof(OwnershipHistory); public const string AssessmentPathwayScore = nameof(AssessmentPathwayScore); @@ -57,7 +59,7 @@ public static class Tables public const string WingInduction = nameof(WingInduction); public const string WingInductionPhase = nameof(WingInductionPhase); - + public const string Notification = nameof(Notification); } public static class Schemas { diff --git a/src/Infrastructure/Persistence/ApplicationDbContext.cs b/src/Infrastructure/Persistence/ApplicationDbContext.cs index 0d3363d4..07746443 100644 --- a/src/Infrastructure/Persistence/ApplicationDbContext.cs +++ b/src/Infrastructure/Persistence/ApplicationDbContext.cs @@ -1,4 +1,4 @@ -using System.Reflection; +using System.Reflection; using Cfo.Cats.Domain.Common.Contracts; using Cfo.Cats.Domain.Entities.Administration; using Cfo.Cats.Domain.Entities.Assessments; @@ -9,6 +9,7 @@ using Cfo.Cats.Infrastructure.Persistence.Configurations.Enrolments; using Microsoft.AspNetCore.DataProtection.EntityFrameworkCore; using Cfo.Cats.Domain.Entities.Inductions; +using Cfo.Cats.Domain.Entities.Notifications; namespace Cfo.Cats.Infrastructure.Persistence; @@ -47,6 +48,8 @@ public ApplicationDbContext(DbContextOptions options) public DbSet ParticipantEnrolmentHistories => Set(); + public DbSet ParticipantLocationHistories => Set(); + public DbSet ParticipantOwnershipHistories => Set(); public DbSet Locations => Set(); @@ -70,6 +73,7 @@ public ApplicationDbContext(DbContextOptions options) public DbSet AccessAuditTrails => Set(); + public DbSet Notifications => Set(); protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); diff --git a/src/Infrastructure/Persistence/Configurations/Notifications/NotificationEntityTypeConfiguration.cs b/src/Infrastructure/Persistence/Configurations/Notifications/NotificationEntityTypeConfiguration.cs new file mode 100644 index 00000000..b72246cf --- /dev/null +++ b/src/Infrastructure/Persistence/Configurations/Notifications/NotificationEntityTypeConfiguration.cs @@ -0,0 +1,63 @@ +using Cfo.Cats.Domain.Entities.Notifications; +using Cfo.Cats.Infrastructure.Constants.Database; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace Cfo.Cats.Infrastructure.Persistence.Configurations.Notifications; + +public class NotificationEntityTypeConfiguration : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable( + DatabaseConstants.Tables.Notification, + DatabaseConstants.Schemas.Identity + ); + + builder.HasKey(x => x.Id).IsClustered(false); + + //make the clustered index based on the created date + builder.HasIndex(x => new { + x.NotificationDate + }, "clst_notification") + .IsClustered(true); + + builder.HasIndex(x => new { + x.OwnerId, + x.NotificationDate, + x.ReadDate + }); + + builder.Property(x => x.Id) + .HasMaxLength(DatabaseConstants.FieldLengths.GuidId); + + builder.HasOne(x => x.Owner) + .WithMany() + .HasForeignKey(x => x.OwnerId); + + builder.Property(x => x.OwnerId) + .IsRequired(); + + builder.Property(x => x.Heading) + .HasMaxLength(50) + .IsRequired(); + + builder.Property(x => x.Details) + .IsRequired(); + + builder.Property(x => x.Link) + .IsRequired(false) + .HasMaxLength(50); + + builder.Property(x => x.CreatedBy) + .IsRequired() + .HasMaxLength(DatabaseConstants.FieldLengths.GuidId); + + builder.Property(x => x.Created) + .IsRequired(); + + builder.Property(x => x.LastModifiedBy) + .HasMaxLength(DatabaseConstants.FieldLengths.GuidId); + + + } +} \ No newline at end of file diff --git a/src/Infrastructure/Persistence/Configurations/Participants/ParticipantEntityTypeConfiguration.cs b/src/Infrastructure/Persistence/Configurations/Participants/ParticipantEntityTypeConfiguration.cs index 5ffb6f58..5028534c 100644 --- a/src/Infrastructure/Persistence/Configurations/Participants/ParticipantEntityTypeConfiguration.cs +++ b/src/Infrastructure/Persistence/Configurations/Participants/ParticipantEntityTypeConfiguration.cs @@ -66,6 +66,14 @@ public void Configure(EntityTypeBuilder builder) cs => cs!.Value, cs => ConsentStatus.FromValue(cs)); + builder.Property(e => e.ArchiveReason) + .HasConversion( + ar => ar!.Value, + ar => ArchiveReason.FromValue(ar)); + + builder.Property(p => p.ArchiveJustification) + .HasMaxLength(ValidationConstants.NotesLength); + builder.HasOne(e => e.CurrentLocation) .WithMany() .HasForeignKey("_currentLocationId") diff --git a/src/Infrastructure/Persistence/Configurations/Participants/ParticipantLocationHistoryConfiguration.cs b/src/Infrastructure/Persistence/Configurations/Participants/ParticipantLocationHistoryConfiguration.cs new file mode 100644 index 00000000..4ebd4059 --- /dev/null +++ b/src/Infrastructure/Persistence/Configurations/Participants/ParticipantLocationHistoryConfiguration.cs @@ -0,0 +1,36 @@ +using Cfo.Cats.Domain.Entities.Administration; +using Cfo.Cats.Domain.Entities.Participants; +using Cfo.Cats.Infrastructure.Constants.Database; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace Cfo.Cats.Infrastructure.Persistence.Configurations.Participants; + +public class ParticipantLocationHistoryConfiguration + : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable( + DatabaseConstants.Tables.LocationHistory, + DatabaseConstants.Schemas.Participant + ); + + builder.HasKey(plh => plh.Id); + + builder.HasOne() + .WithMany() + .HasForeignKey(plh => plh.ParticipantId) + .OnDelete(DeleteBehavior.Restrict); + + builder.HasOne() + .WithMany() + .HasForeignKey(plh => plh.LocationId) + .OnDelete(DeleteBehavior.Restrict); + + builder.Property(plh => plh.CreatedBy) + .HasMaxLength(DatabaseConstants.FieldLengths.GuidId); + + builder.Property(plh => plh.LastModifiedBy) + .HasMaxLength(DatabaseConstants.FieldLengths.GuidId); + } +} diff --git a/src/Infrastructure/Persistence/Configurations/Participants/ParticipantOwnershipHistoryConfiguration.cs b/src/Infrastructure/Persistence/Configurations/Participants/ParticipantOwnershipHistoryConfiguration.cs new file mode 100644 index 00000000..e817158e --- /dev/null +++ b/src/Infrastructure/Persistence/Configurations/Participants/ParticipantOwnershipHistoryConfiguration.cs @@ -0,0 +1,43 @@ +using Cfo.Cats.Domain.Entities.Administration; +using Cfo.Cats.Domain.Entities.Participants; +using Cfo.Cats.Domain.Identity; +using Cfo.Cats.Infrastructure.Constants.Database; +using Microsoft.EntityFrameworkCore.Metadata.Builders; + +namespace Cfo.Cats.Infrastructure.Persistence.Configurations.Participants; + +public class ParticipantOwnershipHistoryConfiguration + : IEntityTypeConfiguration +{ + public void Configure(EntityTypeBuilder builder) + { + builder.ToTable( + DatabaseConstants.Tables.OwnershipHistory, + DatabaseConstants.Schemas.Participant + ); + + builder.HasKey(poh => poh.Id); + + builder.HasOne() + .WithMany() + .HasForeignKey(poh => poh.ParticipantId) + .OnDelete(DeleteBehavior.Restrict); + + builder.HasOne() + .WithMany() + .HasForeignKey(poh => poh.OwnerId) + .OnDelete(DeleteBehavior.Restrict); + + builder.HasOne() + .WithMany() + .HasForeignKey(poh => poh.TenantId) + .OnDelete(DeleteBehavior.Restrict); + + builder.Property(poh => poh.CreatedBy) + .HasMaxLength(DatabaseConstants.FieldLengths.GuidId); + + builder.Property(poh + => poh.LastModifiedBy) + .HasMaxLength(DatabaseConstants.FieldLengths.GuidId); + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20241018130459_ParticipantLocationHistory.Designer.cs b/src/Migrators/Migrators.MSSQL/Migrations/20241018130459_ParticipantLocationHistory.Designer.cs new file mode 100644 index 00000000..ca016094 --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20241018130459_ParticipantLocationHistory.Designer.cs @@ -0,0 +1,3050 @@ +// +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("20241018130459_ParticipantLocationHistory")] + partial class ParticipantLocationHistory + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .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") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + 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") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + 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.ParticipantLocationHistory", 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("From") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("ParticipantId"); + + b.ToTable("LocationHistory", "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.Entities.Participants.EnrolmentQueueEntryNote", "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("IsExternal") + .HasColumnType("bit"); + + 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.Entities.Participants.EnrolmentQueueEntryNote", "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.Entities.Participants.EnrolmentQueueEntryNote", "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("IsExternal") + .HasColumnType("bit"); + + 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.Entities.Participants.EnrolmentQueueEntryNote", "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("IsExternal") + .HasColumnType("bit"); + + 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.ParticipantLocationHistory", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", null) + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + 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/20241018130459_ParticipantLocationHistory.cs b/src/Migrators/Migrators.MSSQL/Migrations/20241018130459_ParticipantLocationHistory.cs new file mode 100644 index 00000000..46d3ee1c --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20241018130459_ParticipantLocationHistory.cs @@ -0,0 +1,69 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Cfo.Cats.Migrators.MSSQL.Migrations +{ + /// + public partial class ParticipantLocationHistory : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "LocationHistory", + schema: "Participant", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ParticipantId = table.Column(type: "nvarchar(9)", nullable: false), + LocationId = table.Column(type: "int", nullable: false), + From = table.Column(type: "datetime2", nullable: false), + Created = table.Column(type: "datetime2", nullable: true), + CreatedBy = table.Column(type: "nvarchar(36)", maxLength: 36, nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(36)", maxLength: 36, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_LocationHistory", x => x.Id); + table.ForeignKey( + name: "FK_LocationHistory_Location_LocationId", + column: x => x.LocationId, + principalSchema: "Configuration", + principalTable: "Location", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_LocationHistory_Participant_ParticipantId", + column: x => x.ParticipantId, + principalSchema: "Participant", + principalTable: "Participant", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_LocationHistory_LocationId", + schema: "Participant", + table: "LocationHistory", + column: "LocationId"); + + migrationBuilder.CreateIndex( + name: "IX_LocationHistory_ParticipantId", + schema: "Participant", + table: "LocationHistory", + column: "ParticipantId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "LocationHistory", + schema: "Participant"); + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20241022111134_ParticipantOwnershipHistory.Designer.cs b/src/Migrators/Migrators.MSSQL/Migrations/20241022111134_ParticipantOwnershipHistory.Designer.cs new file mode 100644 index 00000000..905d0dfb --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20241022111134_ParticipantOwnershipHistory.Designer.cs @@ -0,0 +1,3051 @@ +// +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("20241022111134_ParticipantOwnershipHistory")] + partial class ParticipantOwnershipHistory + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .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") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + 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") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + 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.ParticipantOwnershipHistory", 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("From") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("OwnerId") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.ToTable("OwnershipHistory", "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.Entities.Participants.EnrolmentQueueEntryNote", "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("IsExternal") + .HasColumnType("bit"); + + 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.Entities.Participants.EnrolmentQueueEntryNote", "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.Entities.Participants.EnrolmentQueueEntryNote", "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("IsExternal") + .HasColumnType("bit"); + + 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.Entities.Participants.EnrolmentQueueEntryNote", "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("IsExternal") + .HasColumnType("bit"); + + 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.ParticipantOwnershipHistory", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + 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/20241022111134_ParticipantOwnershipHistory.cs b/src/Migrators/Migrators.MSSQL/Migrations/20241022111134_ParticipantOwnershipHistory.cs new file mode 100644 index 00000000..9c46576c --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20241022111134_ParticipantOwnershipHistory.cs @@ -0,0 +1,69 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Cfo.Cats.Migrators.MSSQL.Migrations +{ + /// + public partial class ParticipantOwnershipHistory : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "OwnershipHistory", + schema: "Participant", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ParticipantId = table.Column(type: "nvarchar(9)", nullable: false), + OwnerId = table.Column(type: "nvarchar(36)", nullable: false), + From = table.Column(type: "datetime2", nullable: false), + Created = table.Column(type: "datetime2", nullable: true), + CreatedBy = table.Column(type: "nvarchar(36)", maxLength: 36, nullable: true), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(36)", maxLength: 36, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_OwnershipHistory", x => x.Id); + table.ForeignKey( + name: "FK_OwnershipHistory_Participant_ParticipantId", + column: x => x.ParticipantId, + principalSchema: "Participant", + principalTable: "Participant", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_OwnershipHistory_User_OwnerId", + column: x => x.OwnerId, + principalSchema: "Identity", + principalTable: "User", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_OwnershipHistory_OwnerId", + schema: "Participant", + table: "OwnershipHistory", + column: "OwnerId"); + + migrationBuilder.CreateIndex( + name: "IX_OwnershipHistory_ParticipantId", + schema: "Participant", + table: "OwnershipHistory", + column: "ParticipantId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "OwnershipHistory", + schema: "Participant"); + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20241025111422_ParticipantOwnershipHistoryTenantId.Designer.cs b/src/Migrators/Migrators.MSSQL/Migrations/20241025111422_ParticipantOwnershipHistoryTenantId.Designer.cs new file mode 100644 index 00000000..35fdefc1 --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20241025111422_ParticipantOwnershipHistoryTenantId.Designer.cs @@ -0,0 +1,3119 @@ +// +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("20241025111422_ParticipantOwnershipHistoryTenantId")] + partial class ParticipantOwnershipHistoryTenantId + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .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") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + 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") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + 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.ParticipantLocationHistory", 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("From") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("ParticipantId"); + + b.ToTable("LocationHistory", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.ParticipantOwnershipHistory", 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("From") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("OwnerId") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("OwnershipHistory", "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.Entities.Participants.EnrolmentQueueEntryNote", "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("IsExternal") + .HasColumnType("bit"); + + 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.Entities.Participants.EnrolmentQueueEntryNote", "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.Entities.Participants.EnrolmentQueueEntryNote", "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("IsExternal") + .HasColumnType("bit"); + + 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.Entities.Participants.EnrolmentQueueEntryNote", "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("IsExternal") + .HasColumnType("bit"); + + 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.ParticipantLocationHistory", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", null) + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.ParticipantOwnershipHistory", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", null) + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + 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/20241025111422_ParticipantOwnershipHistoryTenantId.cs b/src/Migrators/Migrators.MSSQL/Migrations/20241025111422_ParticipantOwnershipHistoryTenantId.cs new file mode 100644 index 00000000..5eafc30d --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20241025111422_ParticipantOwnershipHistoryTenantId.cs @@ -0,0 +1,57 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Cfo.Cats.Migrators.MSSQL.Migrations +{ + /// + public partial class ParticipantOwnershipHistoryTenantId : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "TenantId", + schema: "Participant", + table: "OwnershipHistory", + type: "nvarchar(50)", + nullable: false, + defaultValue: ""); + + migrationBuilder.CreateIndex( + name: "IX_OwnershipHistory_TenantId", + schema: "Participant", + table: "OwnershipHistory", + column: "TenantId"); + + migrationBuilder.AddForeignKey( + name: "FK_OwnershipHistory_Tenant_TenantId", + schema: "Participant", + table: "OwnershipHistory", + column: "TenantId", + principalSchema: "Configuration", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_OwnershipHistory_Tenant_TenantId", + schema: "Participant", + table: "OwnershipHistory"); + + migrationBuilder.DropIndex( + name: "IX_OwnershipHistory_TenantId", + schema: "Participant", + table: "OwnershipHistory"); + + migrationBuilder.DropColumn( + name: "TenantId", + schema: "Participant", + table: "OwnershipHistory"); + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20241101103721_Notifications.Designer.cs b/src/Migrators/Migrators.MSSQL/Migrations/20241101103721_Notifications.Designer.cs new file mode 100644 index 00000000..181ecc95 --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20241101103721_Notifications.Designer.cs @@ -0,0 +1,3197 @@ +// +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("20241101103721_Notifications")] + partial class Notifications + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .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.Notifications.Notification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(36) + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Details") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("Heading") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Link") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("OwnerId") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("ReadDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId", "Created", "ReadDate"); + + b.HasIndex(new[] { "Created" }, "clst_notification"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex(new[] { "Created" }, "clst_notification")); + + b.ToTable("Notification", "Identity"); + }); + + 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") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + 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") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + 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.ParticipantLocationHistory", 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("From") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("ParticipantId"); + + b.ToTable("LocationHistory", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.ParticipantOwnershipHistory", 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("From") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("OwnerId") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("OwnershipHistory", "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.Notifications.Notification", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Editor"); + + b.Navigation("Owner"); + }); + + 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.Entities.Participants.EnrolmentQueueEntryNote", "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("IsExternal") + .HasColumnType("bit"); + + 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.Entities.Participants.EnrolmentQueueEntryNote", "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.Entities.Participants.EnrolmentQueueEntryNote", "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("IsExternal") + .HasColumnType("bit"); + + 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.Entities.Participants.EnrolmentQueueEntryNote", "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("IsExternal") + .HasColumnType("bit"); + + 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.ParticipantLocationHistory", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", null) + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.ParticipantOwnershipHistory", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", null) + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + 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/20241101103721_Notifications.cs b/src/Migrators/Migrators.MSSQL/Migrations/20241101103721_Notifications.cs new file mode 100644 index 00000000..cecf75c4 --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20241101103721_Notifications.cs @@ -0,0 +1,78 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Cfo.Cats.Migrators.MSSQL.Migrations +{ + /// + public partial class Notifications : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Notification", + schema: "Identity", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", maxLength: 36, nullable: false), + Heading = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Details = table.Column(type: "nvarchar(max)", nullable: false), + Link = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + ReadDate = table.Column(type: "datetime2", nullable: true), + Created = table.Column(type: "datetime2", nullable: false), + CreatedBy = table.Column(type: "nvarchar(36)", maxLength: 36, nullable: false), + LastModified = table.Column(type: "datetime2", nullable: true), + LastModifiedBy = table.Column(type: "nvarchar(36)", maxLength: 36, nullable: true), + OwnerId = table.Column(type: "nvarchar(36)", nullable: false), + EditorId = table.Column(type: "nvarchar(36)", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Notification", x => x.Id) + .Annotation("SqlServer:Clustered", false); + table.ForeignKey( + name: "FK_Notification_User_EditorId", + column: x => x.EditorId, + principalSchema: "Identity", + principalTable: "User", + principalColumn: "Id"); + table.ForeignKey( + name: "FK_Notification_User_OwnerId", + column: x => x.OwnerId, + principalSchema: "Identity", + principalTable: "User", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "clst_notification", + schema: "Identity", + table: "Notification", + column: "Created") + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.CreateIndex( + name: "IX_Notification_EditorId", + schema: "Identity", + table: "Notification", + column: "EditorId"); + + migrationBuilder.CreateIndex( + name: "IX_Notification_OwnerId_Created_ReadDate", + schema: "Identity", + table: "Notification", + columns: new[] { "OwnerId", "Created", "ReadDate" }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Notification", + schema: "Identity"); + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20241101110315_Participant_AddArchiveFields.Designer.cs b/src/Migrators/Migrators.MSSQL/Migrations/20241101110315_Participant_AddArchiveFields.Designer.cs new file mode 100644 index 00000000..18ced463 --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20241101110315_Participant_AddArchiveFields.Designer.cs @@ -0,0 +1,3204 @@ +// +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("20241101110315_Participant_AddArchiveFields")] + partial class Participant_AddArchiveFields + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .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.Notifications.Notification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(36) + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Details") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("Heading") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Link") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("OwnerId") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("ReadDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId", "Created", "ReadDate"); + + b.HasIndex(new[] { "Created" }, "clst_notification"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex(new[] { "Created" }, "clst_notification")); + + b.ToTable("Notification", "Identity"); + }); + + 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("ArchiveJustification") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("ArchiveReason") + .HasColumnType("int"); + + 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") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + 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") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + 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.ParticipantLocationHistory", 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("From") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("ParticipantId"); + + b.ToTable("LocationHistory", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.ParticipantOwnershipHistory", 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("From") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("OwnerId") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("OwnershipHistory", "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.Notifications.Notification", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Editor"); + + b.Navigation("Owner"); + }); + + 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.Entities.Participants.EnrolmentQueueEntryNote", "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("IsExternal") + .HasColumnType("bit"); + + 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.Entities.Participants.EnrolmentQueueEntryNote", "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.Entities.Participants.EnrolmentQueueEntryNote", "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("IsExternal") + .HasColumnType("bit"); + + 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.Entities.Participants.EnrolmentQueueEntryNote", "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("IsExternal") + .HasColumnType("bit"); + + 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.ParticipantLocationHistory", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", null) + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.ParticipantOwnershipHistory", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", null) + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + 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/20241101110315_Participant_AddArchiveFields.cs b/src/Migrators/Migrators.MSSQL/Migrations/20241101110315_Participant_AddArchiveFields.cs new file mode 100644 index 00000000..325c5737 --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20241101110315_Participant_AddArchiveFields.cs @@ -0,0 +1,43 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Cfo.Cats.Migrators.MSSQL.Migrations +{ + /// + public partial class Participant_AddArchiveFields : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ArchiveJustification", + schema: "Participant", + table: "Participant", + type: "nvarchar(1000)", + maxLength: 1000, + nullable: true); + + migrationBuilder.AddColumn( + name: "ArchiveReason", + schema: "Participant", + table: "Participant", + type: "int", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ArchiveJustification", + schema: "Participant", + table: "Participant"); + + migrationBuilder.DropColumn( + name: "ArchiveReason", + schema: "Participant", + table: "Participant"); + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/20241108075302_AddNotificationDate.Designer.cs b/src/Migrators/Migrators.MSSQL/Migrations/20241108075302_AddNotificationDate.Designer.cs new file mode 100644 index 00000000..66bc9ed9 --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20241108075302_AddNotificationDate.Designer.cs @@ -0,0 +1,3207 @@ +// +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("20241108075302_AddNotificationDate")] + partial class AddNotificationDate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.10") + .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.Notifications.Notification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(36) + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Details") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("Heading") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Link") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("NotificationDate") + .HasColumnType("datetime2"); + + b.Property("OwnerId") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("ReadDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId", "NotificationDate", "ReadDate"); + + b.HasIndex(new[] { "NotificationDate" }, "clst_notification"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex(new[] { "NotificationDate" }, "clst_notification")); + + b.ToTable("Notification", "Identity"); + }); + + 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("ArchiveJustification") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("ArchiveReason") + .HasColumnType("int"); + + 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") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + 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") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + 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.ParticipantLocationHistory", 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("From") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("ParticipantId"); + + b.ToTable("LocationHistory", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.ParticipantOwnershipHistory", 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("From") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("OwnerId") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("OwnershipHistory", "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.Notifications.Notification", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Editor"); + + b.Navigation("Owner"); + }); + + 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.Entities.Participants.EnrolmentQueueEntryNote", "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("IsExternal") + .HasColumnType("bit"); + + 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.Entities.Participants.EnrolmentQueueEntryNote", "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.Entities.Participants.EnrolmentQueueEntryNote", "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("IsExternal") + .HasColumnType("bit"); + + 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.Entities.Participants.EnrolmentQueueEntryNote", "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("IsExternal") + .HasColumnType("bit"); + + 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.ParticipantLocationHistory", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", null) + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.ParticipantOwnershipHistory", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", null) + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + 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/20241108075302_AddNotificationDate.cs b/src/Migrators/Migrators.MSSQL/Migrations/20241108075302_AddNotificationDate.cs new file mode 100644 index 00000000..d47b3924 --- /dev/null +++ b/src/Migrators/Migrators.MSSQL/Migrations/20241108075302_AddNotificationDate.cs @@ -0,0 +1,78 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Cfo.Cats.Migrators.MSSQL.Migrations +{ + /// + public partial class AddNotificationDate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "clst_notification", + schema: "Identity", + table: "Notification"); + + migrationBuilder.DropIndex( + name: "IX_Notification_OwnerId_Created_ReadDate", + schema: "Identity", + table: "Notification"); + + migrationBuilder.AddColumn( + name: "NotificationDate", + schema: "Identity", + table: "Notification", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.CreateIndex( + name: "clst_notification", + schema: "Identity", + table: "Notification", + column: "NotificationDate") + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.CreateIndex( + name: "IX_Notification_OwnerId_NotificationDate_ReadDate", + schema: "Identity", + table: "Notification", + columns: new[] { "OwnerId", "NotificationDate", "ReadDate" }); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "clst_notification", + schema: "Identity", + table: "Notification"); + + migrationBuilder.DropIndex( + name: "IX_Notification_OwnerId_NotificationDate_ReadDate", + schema: "Identity", + table: "Notification"); + + migrationBuilder.DropColumn( + name: "NotificationDate", + schema: "Identity", + table: "Notification"); + + migrationBuilder.CreateIndex( + name: "clst_notification", + schema: "Identity", + table: "Notification", + column: "Created") + .Annotation("SqlServer:Clustered", true); + + migrationBuilder.CreateIndex( + name: "IX_Notification_OwnerId_Created_ReadDate", + schema: "Identity", + table: "Notification", + columns: new[] { "OwnerId", "Created", "ReadDate" }); + } + } +} diff --git a/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs b/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs index 9f1f128e..8f5fd893 100644 --- a/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/src/Migrators/Migrators.MSSQL/Migrations/ApplicationDbContextModelSnapshot.cs @@ -17,7 +17,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.8") + .HasAnnotation("ProductVersion", "8.0.10") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); @@ -590,6 +590,70 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("KeyValue", "Configuration"); }); + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Notifications.Notification", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(36) + .HasColumnType("uniqueidentifier"); + + b.Property("Created") + .IsRequired() + .HasColumnType("datetime2"); + + b.Property("CreatedBy") + .IsRequired() + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Details") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EditorId") + .HasColumnType("nvarchar(36)"); + + b.Property("Heading") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("Link") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("NotificationDate") + .HasColumnType("datetime2"); + + b.Property("OwnerId") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("ReadDate") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("Id"), false); + + b.HasIndex("EditorId"); + + b.HasIndex("OwnerId", "NotificationDate", "ReadDate"); + + b.HasIndex(new[] { "NotificationDate" }, "clst_notification"); + + SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex(new[] { "NotificationDate" }, "clst_notification")); + + b.ToTable("Notification", "Identity"); + }); + modelBuilder.Entity("Cfo.Cats.Domain.Entities.ParticipantAccessAuditTrail", b => { b.Property("Id") @@ -847,6 +911,13 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("ActiveInFeed") .HasColumnType("bit"); + b.Property("ArchiveJustification") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("ArchiveReason") + .HasColumnType("int"); + b.Property("AssessmentJustification") .HasColumnType("nvarchar(max)"); @@ -980,6 +1051,95 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("EnrolmentHistory", "Participant"); }); + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.ParticipantLocationHistory", 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("From") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("LocationId") + .HasColumnType("int"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.HasKey("Id"); + + b.HasIndex("LocationId"); + + b.HasIndex("ParticipantId"); + + b.ToTable("LocationHistory", "Participant"); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.ParticipantOwnershipHistory", 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("From") + .HasColumnType("datetime2"); + + b.Property("LastModified") + .HasColumnType("datetime2"); + + b.Property("LastModifiedBy") + .HasMaxLength(36) + .HasColumnType("nvarchar(36)"); + + b.Property("OwnerId") + .IsRequired() + .HasColumnType("nvarchar(36)"); + + b.Property("ParticipantId") + .IsRequired() + .HasColumnType("nvarchar(9)"); + + b.Property("TenantId") + .IsRequired() + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("OwnerId"); + + b.HasIndex("ParticipantId"); + + b.HasIndex("TenantId"); + + b.ToTable("OwnershipHistory", "Participant"); + }); + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.PathwayPlan", b => { b.Property("Id") @@ -1866,6 +2026,23 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Phases"); }); + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Notifications.Notification", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Editor") + .WithMany() + .HasForeignKey("EditorId"); + + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", "Owner") + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Editor"); + + b.Navigation("Owner"); + }); + modelBuilder.Entity("Cfo.Cats.Domain.Entities.ParticipantAccessAuditTrail", b => { b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) @@ -2599,6 +2776,42 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Supervisor"); }); + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.ParticipantLocationHistory", b => + { + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Location", null) + .WithMany() + .HasForeignKey("LocationId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.ParticipantOwnershipHistory", b => + { + b.HasOne("Cfo.Cats.Domain.Identity.ApplicationUser", null) + .WithMany() + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Participants.Participant", null) + .WithMany() + .HasForeignKey("ParticipantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Cfo.Cats.Domain.Entities.Administration.Tenant", null) + .WithMany() + .HasForeignKey("TenantId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + modelBuilder.Entity("Cfo.Cats.Domain.Entities.Participants.PathwayPlan", b => { b.OwnsMany("Cfo.Cats.Domain.Entities.Participants.Objective", "Objectives", b1 => diff --git a/src/Server.UI/Components/Shared/Layout/AppLayout.razor b/src/Server.UI/Components/Shared/Layout/AppLayout.razor index 8d4fe4ec..2ebe0bff 100644 --- a/src/Server.UI/Components/Shared/Layout/AppLayout.razor +++ b/src/Server.UI/Components/Shared/Layout/AppLayout.razor @@ -28,16 +28,6 @@ - @if(Env.EnvironmentName is not "Production" && _showAlert) - { - - @Env.EnvironmentName - - } @Body @@ -57,7 +47,6 @@ @code { - private bool _showAlert = true; private bool _commandPaletteOpen; private bool _navigationMenuDrawerOpen = false; private bool _themingDrawerOpen = false; @@ -71,10 +60,7 @@ _userProfile = state.User.GetUserProfileFromClaim(); } - private void CloseMe(bool value) - { - _showAlert = value is false; - } + protected override void OnParametersSet() { diff --git a/src/Server.UI/Components/Shared/Layout/HeaderMenu.razor b/src/Server.UI/Components/Shared/Layout/HeaderMenu.razor index 7e7ee1de..1edd91dd 100644 --- a/src/Server.UI/Components/Shared/Layout/HeaderMenu.razor +++ b/src/Server.UI/Components/Shared/Layout/HeaderMenu.razor @@ -8,7 +8,7 @@ - + HMPPS Case Assessment and Tracking System (CATS) @@ -28,22 +28,9 @@ @**@ - @**@ - - - @* - - *@ - - @**@ - - + OpenSearchDialog.InvokeAsync()); - //.Add(Key.Control, Code.K , () => OpenSearchDialog.InvokeAsync(), "Close command palette."); } + + private void GotoNotifications() => Navigation.NavigateTo("/pages/notifications"); + public void Dispose() { hotKeysContext?.DisposeAsync(); diff --git a/src/Server.UI/Components/Shared/Layout/MainLayout.razor b/src/Server.UI/Components/Shared/Layout/MainLayout.razor index 7bc3f809..96cb7478 100644 --- a/src/Server.UI/Components/Shared/Layout/MainLayout.razor +++ b/src/Server.UI/Components/Shared/Layout/MainLayout.razor @@ -24,9 +24,10 @@ - private System.Timers.Timer? _timer; + private System.Timers.Timer? _timer; + private DateTime _lastActivity = DateTime.Now; + - [Inject] protected IConfiguration Configuration { get; set; } = default!; @@ -49,7 +50,7 @@ StateHasChanged(); int idleTimeOutMinutes = int.Parse(Configuration["IdleTimeoutMinutes"] ?? "20"); - + _timer = new System.Timers.Timer(60000 * idleTimeOutMinutes); _timer.Elapsed += UpdateTimer; @@ -62,24 +63,39 @@ [JSInvokable] public void TimerInterval() { - // Resetting the Timer if the user in active state. + int idleTimeOutMinutes = int.Parse(Configuration["IdleTimeoutMinutes"] ?? "20"); + DateTime maximumAge = _lastActivity.AddMinutes(idleTimeOutMinutes); + if (maximumAge < DateTime.Now) + { + Logout(); + } + else + { + _lastActivity = DateTime.Now; + } + + _timer!.Stop(); - // Call the TimeInterval to logout when the user is inactive. _timer!.Start(); } private void UpdateTimer(object? source, System.Timers.ElapsedEventArgs e) { - InvokeAsync(async() => { - // Log out when the user is inactive. - var authstate = await AuthenticationState; - var user = authstate?.User; - if (user?.Identity is not null && user.Identity.IsAuthenticated) - { - NavigationManager.NavigateTo(IdentityComponentsEndpointRouteBuilderExtensions.Logout, true); - } - }); - } + Logout(); + } + + private void Logout() + { + InvokeAsync(async() => { + // Log out when the user is inactive. + var authstate = await AuthenticationState; + var user = authstate?.User; + if (user?.Identity is not null && user.Identity.IsAuthenticated) + { + NavigationManager.NavigateTo(IdentityComponentsEndpointRouteBuilderExtensions.Logout, true); + } + }); + } private async Task ApplyUserPreferences() { diff --git a/src/Server.UI/Components/Shared/Layout/NotificationMenu.razor b/src/Server.UI/Components/Shared/Layout/NotificationMenu.razor deleted file mode 100644 index 3674db7f..00000000 --- a/src/Server.UI/Components/Shared/Layout/NotificationMenu.razor +++ /dev/null @@ -1,57 +0,0 @@ -@using Cfo.Cats.Server.UI.Services.Notifications -@inherits MudComponentBase - -@inject INotificationService NotificationService -@inject IStringLocalizer L - - - - -
- @L["Notifications"] - @L["Mark as read"] -
- @if (_messages != null && _newNotificationsAvailable) - { - @foreach (var (message, isRead) in _messages.Take(5)) - { - - @message.Title - @($"{message.Authors.FirstOrDefault()?.DisplayName} • {message.PublishDate:MM/dd/yyyy}") - - - } - } - else - { -
- @L["Nothing new :("] -
- } -
-
-
- -@code -{ - private bool _newNotificationsAvailable = false; - private IDictionary? _messages = null; - - private async Task MarkNotificationAsRead() - { - await NotificationService.MarkNotificationsAsRead(); - _newNotificationsAvailable = false; - } - - protected override async Task OnAfterRenderAsync(bool firstRender) - { - if (firstRender) - { - _newNotificationsAvailable = await NotificationService.AreNewNotificationsAvailable(); - _messages = await NotificationService.GetNotifications(); - StateHasChanged(); - } - - await base.OnAfterRenderAsync(firstRender); - } -} \ No newline at end of file diff --git a/src/Server.UI/DependencyInjection.cs b/src/Server.UI/DependencyInjection.cs index 4f38aec8..92924ff8 100644 --- a/src/Server.UI/DependencyInjection.cs +++ b/src/Server.UI/DependencyInjection.cs @@ -8,7 +8,6 @@ using Cfo.Cats.Server.UI.Services.JsInterop; using Cfo.Cats.Server.UI.Services.Layout; using Cfo.Cats.Server.UI.Services.Navigation; -using Cfo.Cats.Server.UI.Services.Notifications; using Cfo.Cats.Server.UI.Services.UserPreferences; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.HttpOverrides; @@ -110,14 +109,7 @@ public static WebApplicationBuilder AddServerUi(this WebApplicationBuilder build .AddScoped() .AddBlazorDownloadFile() .AddScoped() - .AddScoped() - .AddScoped() - .AddScoped(sp => - { - var service = sp.GetRequiredService(); - service.Preload(); - return service; - }); + .AddScoped(); services.Configure(options => diff --git a/src/Server.UI/Pages/Dashboard/Components/LoadingCard.razor b/src/Server.UI/Pages/Dashboard/Components/LoadingCard.razor new file mode 100644 index 00000000..debcc163 --- /dev/null +++ b/src/Server.UI/Pages/Dashboard/Components/LoadingCard.razor @@ -0,0 +1,18 @@ + + + + @Title + + + + + + + +@code { + + [Parameter, EditorRequired] + public string Title { get; set; } = default!; + + +} \ No newline at end of file diff --git a/src/Server.UI/Pages/Dashboard/Components/MyNotifications.razor b/src/Server.UI/Pages/Dashboard/Components/MyNotifications.razor new file mode 100644 index 00000000..8e380862 --- /dev/null +++ b/src/Server.UI/Pages/Dashboard/Components/MyNotifications.razor @@ -0,0 +1,139 @@ +@using Cfo.Cats.Application.Features.Notifications.Command +@using Cfo.Cats.Application.Features.Notifications.DTOs +@using Cfo.Cats.Application.Features.Notifications.Queries +@using Humanizer +@inherits CatsComponentBase + + + + + + + @if (Results is null) + { + + } + + @if (Results is not null) + { + + + + Notifications + + + + Include Read + + + + + + @foreach (var item in Results.Items) + { + +
+
+ @item.Heading + @item.Details + @item.NotificationDate.Humanize() +
+ @if (item.ReadDate is null) + { + + } + else + { + + } + +
+
+ } +
+
+ + + +
+ } +
+ +@code { + + [CascadingParameter] + public UserProfile UserProfile { get; set; } = default!; + + private NotificationsWithPaginationQuery.Query Query { get; set; } = new() + { + PageSize = 5 + }; + + protected override async Task OnInitializedAsync() + { + await OnRefresh(); + } + + + private async Task DismissNotification(Guid id) + { + var result = await GetNewMediator().Send(new MarkAsRead.Command + { + CurrentUser = UserProfile, + NotificationsToMarkAsRead = [id] + }); + await OnRefresh(); + } + + private async Task UnreadNotification(Guid id) + { + var result = await GetNewMediator().Send(new MarkAsUnread.Command + { + CurrentUser = UserProfile, + NotificationsToMarkAsUnread = [id] + }); + await OnRefresh(); + } + + private async Task OnShowClosedChanged(bool value) + { + Query!.ShowReadNotifications = value; + await OnRefresh(); + } + + private async Task OnRefresh() + { + Query.CurrentUser = UserProfile; + Query.OrderBy = "NotificationDate"; + Query.SortDirection = SortDirection.Descending.ToString(); + Results = await GetNewMediator().Send(Query).ConfigureAwait(false); + } + + PaginatedData? Results { get; set; } + + private Task OnPaginationChanged(int arg) + { + Query.PageNumber = arg; + return OnRefresh(); + } + + + private async Task OnShowUnreadChanged(bool value) + { + Query!.ShowReadNotifications = value; + await OnRefresh(); + } + + private void GotoNotification(string? itemLink) + { + if (itemLink is not null) + { + Navigation.NavigateTo(itemLink); + } + } + +} \ No newline at end of file diff --git a/src/Server.UI/Pages/Dashboard/Components/MyParticipantsComponent.razor b/src/Server.UI/Pages/Dashboard/Components/MyParticipantsComponent.razor new file mode 100644 index 00000000..dd45fbef --- /dev/null +++ b/src/Server.UI/Pages/Dashboard/Components/MyParticipantsComponent.razor @@ -0,0 +1,110 @@ +@using Cfo.Cats.Application.Features.Dashboard.Queries +@using Cfo.Cats.Application.Features.Dashboard.DTOs +@using Cfo.Cats.Application.Features.Participants.Specifications + +@inherits CatsComponentBase + + +@if (_participantSteps is null) +{ + +} + +@if (_participantSteps is not null) +{ + + + + My Participants + + + + + +
+ Identified + @_participantSteps.IdentifiedCases +
+
+ +
+ Enrolling + @_participantSteps.EnrollingCases +
+
+ +
+ Submitted to PQA + @_participantSteps.CasesAtPqa +
+
+ +
+ Submitted to Authority + @_participantSteps.CasesAtCfo +
+
+ +
+ Approved + @_participantSteps.ApprovedCases +
+
+
+
+ + View All + +
+} +
+ +@code { + + + [CascadingParameter] + public UserProfile? UserProfile { get; set; } + + private double[] _data = []; + + private readonly string[] _labels = + [ + "Identified", + "Enrolling", + "Submitted To PQA", + "Submitted To Authority", + "Approved" + ]; + + private string GetParticipantsUrl(ParticipantListView listView) => $"/pages/participants?listView={listView.ToString()}"; + + private ParticipantCountSummaryDto? _participantSteps; + + protected override async Task OnInitializedAsync() + { + var query = new GetMyParticipantsDashboard.Query() + { + CurrentUser = UserProfile! + }; + + var result = await GetNewMediator().Send(query); + + if (result.Succeeded) + { + _participantSteps = result.Data; + _data = + [ + _participantSteps!.IdentifiedCases, + _participantSteps.EnrollingCases, + _participantSteps.CasesAtPqa, + _participantSteps.CasesAtCfo, + _participantSteps.ApprovedCases + ]; + } + } + + + private void GotoParticipants() => Navigation.NavigateTo("/pages/participants"); + + +} \ No newline at end of file diff --git a/src/Server.UI/Pages/Dashboard/Components/MyTeamsParticipantsComponent.razor b/src/Server.UI/Pages/Dashboard/Components/MyTeamsParticipantsComponent.razor new file mode 100644 index 00000000..6b7f901a --- /dev/null +++ b/src/Server.UI/Pages/Dashboard/Components/MyTeamsParticipantsComponent.razor @@ -0,0 +1,132 @@ +@using Cfo.Cats.Application.Features.Dashboard.Queries +@using Cfo.Cats.Application.Features.Dashboard.DTOs +@using Cfo.Cats.Application.Features.Participants.Specifications +@inherits CatsComponentBase + + +@if (_participantSteps is null) +{ + + + + + + +} + +@if (_participantSteps is not null) +{ + + + + + Participants + + + + + +
+ Identified + @_participantSteps.IdentifiedCases +
+
+ +
+ Enrolling + @_participantSteps.EnrollingCases +
+
+ +
+ Submitted to PQA + @_participantSteps.CasesAtPqa +
+
+ +
+ Submitted to Authority + @_participantSteps.CasesAtCfo +
+
+ +
+ Approved + @_participantSteps.ApprovedCases +
+
+
+
+ + View + +
+
+ + + + Participants Breakdown + + + + + + + + + View All + + + + +} + +@code { + + + [CascadingParameter] + public UserProfile? UserProfile { get; set; } + + private double[] _data = []; + + private readonly string[] _labels = + [ + "Identified", + "Enrolling", + "Submitted To PQA", + "Submitted To Authority", + "Approved" + ]; + + private ParticipantCountSummaryDto? _participantSteps; + + protected override async Task OnInitializedAsync() + { + var query = new GetMyTeamsParticipantsDashboard.Query() + { + CurrentUser = UserProfile! + }; + + var result = await GetNewMediator().Send(query); + + if (result.Succeeded) + { + _participantSteps = result.Data; + _data = + [ + _participantSteps!.IdentifiedCases, + _participantSteps.EnrollingCases, + _participantSteps.CasesAtPqa, + _participantSteps.CasesAtCfo, + _participantSteps.ApprovedCases + ]; + } + } + + + private string GetParticipantsUrl(ParticipantListView listView) => $"/pages/participants?listView={listView.ToString()}"; + + + private void GotoParticipants() => Navigation.NavigateTo("/pages/participants"); + +} \ No newline at end of file diff --git a/src/Server.UI/Pages/Dashboard/Dashboard.razor b/src/Server.UI/Pages/Dashboard/Dashboard.razor index 0e384d0c..b8a3d795 100644 --- a/src/Server.UI/Pages/Dashboard/Dashboard.razor +++ b/src/Server.UI/Pages/Dashboard/Dashboard.razor @@ -1,105 +1,30 @@ @page "/" @using Cfo.Cats.Application.Features.Dashboard.Queries @using Cfo.Cats.Application.SecurityConstants +@using Cfo.Cats.Server.UI.Pages.Dashboard.Components @inherits CatsComponentBase @attribute [Authorize(Policy = SecurityPolicies.AuthorizedUser)] -@Title - - Dashboard - - - - - - - Identified Cases - - - - - Your cases that are awaiting enrolment confirmation - - @_dashboardDto?.IdentifiedCases - - - - - - - - - - Enrolling Cases - - - - - Your cases that are awaiting submission to PQA - - @_dashboardDto?.EnrollingCases - - - - - - - - - - Provider QA - - - - - Your cases that are sat with Provider QA - - @_dashboardDto?.CasesAtPqa - - - - - - - - - - CFO QA - - - - - Your cases that are sat with CFO QA - - @_dashboardDto?.CasesAtCfo - - - - - - - - - - Approved Cases - - - - - Your cases that have been approved - - @_dashboardDto?.ApprovedCases - - - - - - + + + + @if(UserProfile?.AssignedRoles?.Length == 0) + { + + } + else + { + + } + + + + @@ -107,25 +32,12 @@ public string Title { get; } = "Dashboard"; - private DashboardDto? _dashboardDto = null; - + + [CascadingParameter] public UserProfile? UserProfile { get; set; } - protected override async Task OnInitializedAsync() - { - var query = new GetDashboard.Query() - { - CurrentUser = UserProfile! - }; - - var result = await GetNewMediator().Send(query); - - if (result.Succeeded) - { - _dashboardDto = result.Data; - } - - } + + private void GotoNotification() => Navigation.NavigateTo("/pages/notifications/"); } diff --git a/src/Server.UI/Pages/Participants/Components/ArchiveCaseDialog.razor b/src/Server.UI/Pages/Participants/Components/ArchiveCaseDialog.razor new file mode 100644 index 00000000..c6d6bbd4 --- /dev/null +++ b/src/Server.UI/Pages/Participants/Components/ArchiveCaseDialog.razor @@ -0,0 +1,76 @@ +@using Cfo.Cats.Application.Features.QualityAssurance.Commands +@using Cfo.Cats.Domain.Common.Enums + +@inject IValidationService Validator + + + + + + @ArchiveReason.CaseloadTooHigh.Name + @ArchiveReason.Deceased.Name + @ArchiveReason.LicenceEnd.Name + @ArchiveReason.MovedOutsideProviderArea.Name + @ArchiveReason.MovedToNonCFO.Name + @ArchiveReason.NoFurtherSupport.Name + @ArchiveReason.NoRightToLiveWork.Name + @ArchiveReason.NoWishToParticipate.Name + @ArchiveReason.NoLongerEngaging.Name + @ArchiveReason.PersonalCircumstances.Name + @ArchiveReason.Other.Name + + + + + + + @ConstantString.Cancel + @ConstantString.Archive + + + +@code { + bool saving = false; + MudForm? form; + + [CascadingParameter] private MudDialogInstance MudDialog { get; set; } = default!; + + [Parameter, EditorRequired] + public required ArchiveCase.Command Model { get; set; } + + private void Cancel() + { + MudDialog.Cancel(); + } + + private async Task Submit() + { + try + { + saving = true; + + if(form is null) + { + saving = false; + return; + } + + await form.Validate(); + + if(form.IsValid) + { + MudDialog.Close(DialogResult.Ok(true)); + } + } + finally + { + saving = false; + } + } +} \ No newline at end of file diff --git a/src/Server.UI/Pages/Participants/Components/Inductions.razor b/src/Server.UI/Pages/Participants/Components/Inductions.razor index 06587692..287c66d1 100644 --- a/src/Server.UI/Pages/Participants/Components/Inductions.razor +++ b/src/Server.UI/Pages/Participants/Components/Inductions.razor @@ -154,7 +154,7 @@ var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.Small, FullWidth = true }; var dialog = DialogService.Show - ("Add a hub induction", parameters, options); + ("Add a Hub Induction", parameters, options); var state = await dialog.Result; @@ -180,7 +180,7 @@ var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.Small, FullWidth = true }; var dialog = DialogService.Show - ("Add a wing induction", parameters, options); + ("Add a Wing Induction", parameters, options); var state = await dialog.Result; @@ -253,7 +253,7 @@ FullWidth = true }; var dialog = DialogService.Show - ("Complete induction phase", parameters, options); + ("Complete Wing Phase", parameters, options); var state = await dialog.Result; diff --git a/src/Server.UI/Pages/Participants/Components/ParticipantActionMenu.razor b/src/Server.UI/Pages/Participants/Components/ParticipantActionMenu.razor index b3d3bfc9..942d295b 100644 --- a/src/Server.UI/Pages/Participants/Components/ParticipantActionMenu.razor +++ b/src/Server.UI/Pages/Participants/Components/ParticipantActionMenu.razor @@ -44,8 +44,6 @@ } - -
@@ -60,7 +58,6 @@ [CascadingParameter] public UserProfile UserProfile { get; set; } = default!; - protected override async Task OnInitializedAsync() { var state = await AuthState; @@ -71,21 +68,23 @@ protected async Task Archive() { - var parameters = new DialogParameters() - { - { x => x.ContentText, "Are you sure you would like to archive this case?" } - }; - - var dialog = await DialogService.ShowAsync("Archive", parameters); - var dialogResult = await dialog.Result; + var command = new ArchiveCase.Command() + { + ParticipantId = Participant.Id + }; - if (dialogResult?.Canceled is not true) - { - var command = new ArchiveCase.Command() + var parameters = new DialogParameters() { - ParticipantId = Participant.Id + { x => x.Model,command} }; + var options = new DialogOptions { CloseButton = true, MaxWidth = MaxWidth.Small, FullWidth = true }; + var dialog = DialogService.Show("Archive Case", parameters, options); + + var state = await dialog.Result; + + if (state!.Canceled is false) + { var result = await GetNewMediator().Send(command); if (result.Succeeded) @@ -96,9 +95,7 @@ { ShowActionFailure("Failed to archive", result); } - - } - + } } protected async Task Suspend() @@ -114,9 +111,9 @@ if (dialogResult?.Canceled is not true) { var command = new SuspendCase.Command() - { - ParticipantId = Participant.Id - }; + { + ParticipantId = Participant.Id + }; var result = await GetNewMediator().Send(command); if (result.Succeeded) @@ -127,9 +124,7 @@ { ShowActionFailure("Failed to suspend", result); } - } - } protected async Task SubmitToPqa() @@ -170,7 +165,6 @@ await SubmitToPqa(); } } - } protected async Task OpenRightToWorkDialog() @@ -192,12 +186,10 @@ { dialog.Close(); } - } protected async Task OpenAdjustLocationDialog() { - var parameters = new DialogParameters() { { x => x.UserProfile, this.UserProfile }, @@ -235,8 +227,8 @@ { dialog.Close(); } - } + private void ShowActionFailure(string title, IResult result) { Snackbar.Add( @@ -254,5 +246,4 @@ options.SnackbarVariant = Variant.Text; } ); } - } diff --git a/src/Server.UI/Pages/Participants/Participants.razor b/src/Server.UI/Pages/Participants/Participants.razor index ef89a6f7..9e9e9971 100644 --- a/src/Server.UI/Pages/Participants/Participants.razor +++ b/src/Server.UI/Pages/Participants/Participants.razor @@ -1,4 +1,5 @@ @page "/pages/participants" + @using Cfo.Cats.Application.Common.Interfaces.Locations @using Cfo.Cats.Application.Features.Locations.DTOs @using Cfo.Cats.Domain.Common.Enums @@ -21,34 +22,36 @@ } - - -
-
- -
- @L[_currentDto.GetClassDescription()] - - -
-
- - +@if (Query is not null) +{ + + +
+
+ +
+ @L[_currentDto.GetClassDescription()] + + +
+
+ + @foreach (var item in Locations!) { @@ -56,125 +59,105 @@ @item.Name } - - -
-
- + + +
+
+ +
-
-
-
-
- - - @ConstantString.Refresh - - @if (_canEnrol) - { +
+
+
+ - @ConstantString.NewEnrolment + @ConstantString.Refresh - } - - - - -
- @if (_canSearch) - { - - - } -
-
- - - - - - - @if (context.Item.EnrolmentStatus == EnrolmentStatus.IdentifiedStatus) - { - // Candidate has been identified. Allow a continuation of the enrolment process. - - @ConstantString.ResumeEnrolment - - } - else + @if (_canEnrol) + { + + @ConstantString.NewEnrolment + + } + + + + +
+ @if (_canSearch) { - - @ConstantString.Edit - + + } - - - - - -
- @context.Item.ParticipantName - @context.Item.Id
-
-
- - -
-
- +
+ + + + + + + @if (context.Item.EnrolmentStatus == EnrolmentStatus.IdentifiedStatus) + { + // Candidate has been identified. Allow a continuation of the enrolment process. + + @ConstantString.ResumeEnrolment + + } + else + { + + @ConstantString.Edit + + } + + + + + +
+ @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) + + + + +
+
+ +
+
+
+
+ + +
+ @if (context.Item.CurrentLocation.LocationType.IsCustody) { } @@ -182,38 +165,64 @@ { } - @context.Item.EnrolmentLocation?.Name - } -
-
-
- - -
- @context.Item.Owner - @context.Item.Tenant -
-
-
- - - @ConstantString.NoRecords - - - @ConstantString.Loading - - - - - + @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 { [Inject] public ILocationService LocationService {get;set;} = default!; + [SupplyParameterFromQuery(Name="ListView")] + public string? ListView { get; set; } + public string? Title { get; private set; } private int _defaultPageSize = 15; @@ -228,7 +237,7 @@ private ParticipantPaginationDto _currentDto = new() { Id = "" }; - private ParticipantsWithPagination.Query Query { get; set; } = new(); + private ParticipantsWithPagination.Query? Query { get; set; } private void OnResumeEnrolment(ParticipantPaginationDto participant) { @@ -240,9 +249,9 @@ return $"{selectedValues.Count} location{(selectedValues.Count > 1 ? "s have":" has")} been selected"; } - private async Task LocationValuesChanged(IEnumerable selectedValues) + private async Task LocationValuesChanged(IEnumerable? selectedValues) { - Query.Locations = selectedValues.Select(l => l.Id).ToArray(); + Query!.Locations = selectedValues!.Select(l => l.Id).ToArray(); await _table.ReloadServerData(); } @@ -256,7 +265,7 @@ private async Task OnShowEveryoneChanged(bool value) { - Query.JustMyCases = value; + Query!.JustMyCases = value; await _table.ReloadServerData(); } @@ -266,7 +275,18 @@ 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(); + + Enum.TryParse(ListView, true, out var selectedListView); + + Query = new ParticipantsWithPagination.Query() + { + JustMyCases = UserProfile!.AssignedRoles.Length == 0, + ListView = selectedListView, + }; + + Locations = LocationService.GetVisibleLocations(UserProfile!.TenantId!) + .OrderByDescending(l => l.LocationType.IsCustody) + .ThenBy(l => l.Name).ToArray(); } private async Task> ServerReload(GridState state) @@ -274,7 +294,7 @@ try { _loading = true; - Query.CurrentUser = UserProfile; + 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; @@ -295,13 +315,13 @@ return; } _selectedItems = new(); - Query.Keyword = text; + Query!.Keyword = text; await _table.ReloadServerData(); } private async Task OnChangedListView(ParticipantListView listview) { - Query.ListView = listview; + Query!.ListView = listview; await _table.ReloadServerData(); } @@ -309,7 +329,7 @@ { ParticipantCacheKey.Refresh(); _selectedItems = []; - Query.Keyword = string.Empty; + Query!.Keyword = string.Empty; await _table.ReloadServerData(); } diff --git a/src/Server.UI/Services/Notifications/INotificationService.cs b/src/Server.UI/Services/Notifications/INotificationService.cs deleted file mode 100644 index c9843ecf..00000000 --- a/src/Server.UI/Services/Notifications/INotificationService.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace Cfo.Cats.Server.UI.Services.Notifications; - -public interface INotificationService -{ - Task AreNewNotificationsAvailable(); - Task MarkNotificationsAsRead(); - Task MarkNotificationsAsRead(string id); - Task GetMessageById(string id); - Task> GetNotifications(); - Task AddNotification(NotificationMessage message); -} - -public record NotificationAuthor(string DisplayName, string AvatarUlr); - -public record NotificationMessage( - string Id, - string Title, - string Except, - string Category, - DateTime PublishDate, - string ImgUrl, - IEnumerable Authors, - Type ContentComponent -); diff --git a/src/Server.UI/Services/Notifications/InMemoryNotificationService.cs b/src/Server.UI/Services/Notifications/InMemoryNotificationService.cs deleted file mode 100644 index 744f5951..00000000 --- a/src/Server.UI/Services/Notifications/InMemoryNotificationService.cs +++ /dev/null @@ -1,110 +0,0 @@ -using System.Security.Cryptography; -using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage; - -namespace Cfo.Cats.Server.UI.Services.Notifications; - -public class InMemoryNotificationService : INotificationService -{ - private const string LocalStorageKey = "__notficationTimestamp"; - private readonly ProtectedLocalStorage localStorageService; - private readonly ILogger logger; - - private readonly List messages; - - public InMemoryNotificationService( - ProtectedLocalStorage localStorageService, - ILogger logger - ) - { - this.localStorageService = localStorageService; - this.logger = logger; - messages = new List(); - } - - public async Task AreNewNotificationsAvailable() - { - var timestamp = await GetLastReadTimestamp(); - var entriesFound = messages.Any(x => x.PublishDate > timestamp); - - return entriesFound; - } - - public async Task MarkNotificationsAsRead() - { - await localStorageService.SetAsync(LocalStorageKey, DateTime.Now.Date); - } - - public async Task MarkNotificationsAsRead(string id) - { - var message = await GetMessageById(id); - if (message == null) - { - return; - } - - var timestamp = await localStorageService.GetAsync(LocalStorageKey); - if (timestamp.Success) - { - await localStorageService.SetAsync(LocalStorageKey, message.PublishDate); - } - } - - public Task GetMessageById(string id) - { - return Task.FromResult(messages.First(x => x.Id == id)); - } - - public async Task> GetNotifications() - { - var lastReadTimestamp = await GetLastReadTimestamp(); - var items = messages.ToDictionary(x => x, x => lastReadTimestamp > x.PublishDate); - return items; - } - - public Task AddNotification(NotificationMessage message) - { - messages.Add(message); - return Task.CompletedTask; - } - - private async Task GetLastReadTimestamp() - { - try - { - if ((await localStorageService.GetAsync(LocalStorageKey)).Success == false) - { - return DateTime.MinValue; - } - - var timestamp = await localStorageService.GetAsync(LocalStorageKey); - return timestamp.Value; - } - catch (CryptographicException) - { - await localStorageService.DeleteAsync(LocalStorageKey); - return DateTime.MinValue; - } - } - - public void Preload() - { - messages.Add( - new NotificationMessage( - "readme", - "Cats is ready", - "We are paving the way for the future of CFO", - "Announcement", - new DateTime(2022, 01, 13), - "", - new[] - { - new NotificationAuthor( - "Carl Sixsmith", - "https://avatars.githubusercontent.com/u/9332472?s=400&u=73c208bf07ba967d5407aae9068580539cfc80a2&v=4" - ) - }, - typeof(NotificationMessage) - ) - ); - } -} diff --git a/test/playwright/auth.spec.ts b/test/playwright/auth.spec.ts new file mode 100644 index 00000000..eb5f8c3c --- /dev/null +++ b/test/playwright/auth.spec.ts @@ -0,0 +1,62 @@ +import { test, expect, Locator } from '@playwright/test'; +import * as users from './test-data/users.json' + +test('is alive', async ({ page }) => { + await page.goto('/'); + + // Expect a title "to contain" a substring. + await expect(page).toHaveTitle("Case Assessment and Tracking System (CATS)"); +}); + +test('login unsuccessfully with invalid credentials', async ({ page }) => { + await page.goto('/'); + + let preLoginUrl = page.url(); + + // Expects page to have a heading with the name of Sign In. + await expect(page.getByRole('heading', { name: 'Sign In' })).toBeVisible(); + + let form = page.locator('form'); + + await login(form, { + username: "john.doe@example.com", + password: "IncorrectPassword12345!" + }); + + // Expects "Invalid login attempt" alert + await expect(form.getByRole('alert')).toContainText("Invalid login attempt"); + + // Expects unsuccessful navigation, remaining on the login page + await expect(page).toHaveURL(preLoginUrl); +}); + +test('login successfully with valid credentials', async ({ page }) => { + await page.goto('/'); + + // Expects page to have a heading with the name of Sign In. + await expect(page.getByRole('heading', { name: 'Sign In' })).toBeVisible(); + + let form = page.locator('form'); + + await login(form, { + username: users.regular.username, + password: users.regular.password + }); + + // Expect dashboard to be visible + await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible(); + + // Expect successful navigation, navigating away from login page + await expect(page).toHaveURL('/'); +}); + +async function login(form: Locator, user: User) { + await form.locator('input[type="text"]').fill(user.username); + await form.locator('input[type="password"]').fill(user.password); + await form.locator('button[type="submit"]').click(); +} + +interface User { + username: string; + password: string; +} \ No newline at end of file diff --git a/test/playwright/test-data/users.json b/test/playwright/test-data/users.json new file mode 100644 index 00000000..6326f508 --- /dev/null +++ b/test/playwright/test-data/users.json @@ -0,0 +1,14 @@ +{ + "regular": { + "username": "qa.officer@justice.gov.uk", + "password": "Password123!" + }, + "smt": { + "username": "smt@justice.gov.uk", + "password": "Password123!" + }, + "support": { + "username": "system.support@justice.gov.uk", + "password": "Password123!" + } +} \ No newline at end of file