Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cfodev 422 create database context and entities for enrolments #23

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4742ee1
adjust events etc, create history of enrolment
carlsixsmith-moj Jun 6, 2024
caaca6d
adjust events etc, create history of enrolment
carlsixsmith-moj Jun 6, 2024
d0b016a
Merge branch 'CFODEV-422-create-database-context-and-entities-for-enr…
carlsixsmith-moj Jun 9, 2024
ecdc4e0
adjust events etc, create history of enrolment
carlsixsmith-moj Jun 6, 2024
42ed73a
Merge branch 'CFODEV-422-create-database-context-and-entities-for-enr…
carlsixsmith-moj Jun 10, 2024
83cdcaa
use strings rather than ints for identity
carlsixsmith-moj Jun 10, 2024
cefeb62
More participant stuff. + cleanup of dependencies (for example, we lo…
carlsixsmith-moj Jun 12, 2024
e1de247
Clean up security model. Remove massive permissions list and create p…
carlsixsmith-moj Jun 13, 2024
e799007
tenant locaations etc
carlsixsmith-moj Jun 14, 2024
3b5c610
adjust events etc, create history of enrolment
carlsixsmith-moj Jun 6, 2024
d15bd31
use strings rather than ints for identity
carlsixsmith-moj Jun 10, 2024
22d2906
More participant stuff. + cleanup of dependencies (for example, we lo…
carlsixsmith-moj Jun 12, 2024
63cd12a
Clean up security model. Remove massive permissions list and create p…
carlsixsmith-moj Jun 13, 2024
15db222
tenant locations etc
carlsixsmith-moj Jun 14, 2024
2c1d135
Merge branch 'CFODEV-422-create-database-context-and-entities-for-enr…
carlsixsmith-moj Jun 16, 2024
61051c7
Fix naming of Event -> DomainEvent. Add handler for the event so tena…
carlsixsmith-moj Jun 16, 2024
d6d94bb
Fix issues with authentication changes.
carlsixsmith-moj Jun 17, 2024
f5cf869
Enrolment location is being persisted now
carlsixsmith-moj Jun 17, 2024
a24fa95
Much cleaner control flow
carlsixsmith-moj Jun 17, 2024
9b34aa8
Start of upload to aws
carlsixsmith-moj Jun 17, 2024
56cbd66
WIP - Upload to S3 works.
carlsixsmith-moj Jun 17, 2024
3541f8f
Store consent in the database, adjust columns on participants screen …
carlsixsmith-moj Jun 18, 2024
bf46b3f
Allow consent to be remembered
carlsixsmith-moj Jun 18, 2024
239beef
Remove dependency on Hangfire.
carlsixsmith-moj Jun 19, 2024
c2e63e5
Fix permissions on AddKeyValueCommand
carlsixsmith-moj Jun 19, 2024
a3e7c01
upgrade to mud 7 (still in RC but better for long term due to breakin…
carlsixsmith-moj Jun 20, 2024
11970b7
Mud V7
carlsixsmith-moj Jun 24, 2024
30c5b9b
Right to Work: WIP
carlsixsmith-moj Jun 24, 2024
b0ddde1
Enrolment up to submission
carlsixsmith-moj Jun 25, 2024
50a5c99
Changes to address the broken build
carlsixsmith-moj Jun 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@
"cwd": "${workspaceFolder}/build",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": ".net Core Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickProcess}",
"justMyCode": false
}
]
}
7 changes: 0 additions & 7 deletions cats.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Migrators.MSSQL", "src\Migr
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Migrators.SqLite", "src\Migrators\Migrators.SqLite\Migrators.SqLite.csproj", "{426EFDAD-6A43-40DC-8954-7E2CE6056687}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server", "src\Server\Server.csproj", "{7721D89A-D919-41A8-8B5B-8D5BF862B3F7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Server.UI", "src\Server.UI\Server.UI.csproj", "{50485EFF-8E12-4F8A-A087-A9882D2C31C7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_SolutionItems", "_SolutionItems", "{1B26F38D-22D1-4A00-B3D3-D77C5979281B}"
Expand Down Expand Up @@ -65,10 +63,6 @@ Global
{426EFDAD-6A43-40DC-8954-7E2CE6056687}.Debug|Any CPU.Build.0 = Debug|Any CPU
{426EFDAD-6A43-40DC-8954-7E2CE6056687}.Release|Any CPU.ActiveCfg = Release|Any CPU
{426EFDAD-6A43-40DC-8954-7E2CE6056687}.Release|Any CPU.Build.0 = Release|Any CPU
{7721D89A-D919-41A8-8B5B-8D5BF862B3F7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7721D89A-D919-41A8-8B5B-8D5BF862B3F7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7721D89A-D919-41A8-8B5B-8D5BF862B3F7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7721D89A-D919-41A8-8B5B-8D5BF862B3F7}.Release|Any CPU.Build.0 = Release|Any CPU
{50485EFF-8E12-4F8A-A087-A9882D2C31C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{50485EFF-8E12-4F8A-A087-A9882D2C31C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{50485EFF-8E12-4F8A-A087-A9882D2C31C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -96,7 +90,6 @@ Global
{3798C2B2-CF3E-4EB7-B1E1-62FABE54FF46} = {28581377-5421-47F6-A678-9510117A7791}
{A7B309FF-FFA9-4290-B982-46DA80D0E0DF} = {3798C2B2-CF3E-4EB7-B1E1-62FABE54FF46}
{426EFDAD-6A43-40DC-8954-7E2CE6056687} = {3798C2B2-CF3E-4EB7-B1E1-62FABE54FF46}
{7721D89A-D919-41A8-8B5B-8D5BF862B3F7} = {28581377-5421-47F6-A678-9510117A7791}
{50485EFF-8E12-4F8A-A087-A9882D2C31C7} = {28581377-5421-47F6-A678-9510117A7791}
{2FC2E6B9-5186-4A39-A2CC-0975ED2AEC1E} = {62ABFE2F-D4F3-4E44-AA07-20D679B04CF3}
{386B9FE9-E2C6-443A-A8EE-D1DC79E867C6} = {62ABFE2F-D4F3-4E44-AA07-20D679B04CF3}
Expand Down
513 changes: 237 additions & 276 deletions db/seed/001_development_seed.sql

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
services:
seq:
image: datalust/seq
container_name: seq
environment:
ACCEPT_EULA: "Y"
ports:
- "5341:80"
volumes:
- seq_data:/data

sqlserver:
image: mcr.microsoft.com/mssql/server:2022-latest
container_name: sqlserver
environment:
ACCEPT_EULA: "Y"
SA_PASSWORD: "YourStrong@Passw0rd"
TZ: "Europe/London"
ports:
- "1433:1433"
volumes:
- sqlserver_data:/var/opt/mssql

volumes:
seq_data:
driver: local
sqlserver_data:
driver: local
6 changes: 2 additions & 4 deletions src/Application/Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.6" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="8.0.6" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.0" />
<PackageReference Include="Hangfire.Core" Version="1.8.14" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Domain\Domain.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Common\Interfaces\Identity\DTOs\" />
<Folder Include="Features\Assessments\Queries\" />
<Folder Include="Features\Identity\Notifications\" />
<None Remove="DependencyInjection.cs.bak" />
<None Remove="Application.csproj.bak" />
</ItemGroup>
</Project>
7 changes: 6 additions & 1 deletion src/Application/Common/Interfaces/IApplicationDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Cfo.Cats.Domain.Entities.Candidates;
using Cfo.Cats.Domain.Entities.Documents;
using Cfo.Cats.Domain.Entities.Participants;
using Cfo.Cats.Domain.Identity;
using Microsoft.AspNetCore.DataProtection.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;

Expand All @@ -23,7 +24,11 @@ public interface IApplicationDbContext
public DbSet<KeyValue> KeyValues { get; }

public DbSet<Candidate> Candidates { get; }


public DbSet<ParticipantEnrolmentHistory> ParticipantEnrolmentHistories { get; }

public DbSet<ApplicationUser> Users { get; }

ChangeTracker ChangeTracker { get; }

DbSet<DataProtectionKey> DataProtectionKeys { get; }
Expand Down
17 changes: 17 additions & 0 deletions src/Application/Common/Interfaces/IApplicationSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Cfo.Cats.Application.Common.Interfaces;

public interface IApplicationSettings
{
string App { get; set; }
string AppFlavor { get; set; }
string AppFlavorSubscript { get; set; }
string ApplicationUrl { get; set; }
string AppName { get; set; }
bool BehindSSLProxy { get; set; }
string Company { get; set; }
string Copyright { get; set; }
string ProxyIP { get; set; }
bool Resilience { get; set; }
string Secret { get; set; }
string Version { get; set; }
}
2 changes: 1 addition & 1 deletion src/Application/Common/Interfaces/ICurrentUserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public interface ICurrentUserService
{
int? UserId { get; }
string? UserId { get; }
string? UserName { get; }
string? TenantId { get; }
string? TenantName { get; }
Expand Down
3 changes: 2 additions & 1 deletion src/Application/Common/Interfaces/IUploadService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@

public interface IUploadService
{
Task<string> UploadAsync(UploadRequest request);
Task<Result<string>> UploadAsync(string folder, UploadRequest request);
Task<Result<Stream>> DownloadAsync(string key);
}
32 changes: 10 additions & 22 deletions src/Application/Common/Interfaces/Identity/IIdentityService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,14 @@ namespace Cfo.Cats.Application.Common.Interfaces.Identity;

public interface IIdentityService
{
Task<string?> GetUserNameAsync(int userId, CancellationToken cancellation = default);
Task<bool> IsInRoleAsync(int userId, string role, CancellationToken cancellation = default);
Task<bool> AuthorizeAsync(
int userId,
string policyName,
CancellationToken cancellation = default
);
Task<Result> DeleteUserAsync(int userId, CancellationToken cancellation = default);
Task<IDictionary<string, string?>> FetchUsers(
string roleName,
CancellationToken cancellation = default
);
Task UpdateLiveStatus(int userId, bool isLive, CancellationToken cancellation = default);
Task<ApplicationUserDto> GetApplicationUserDto(
string userName,
CancellationToken cancellation = default
);
string GetUserName(int userId);
Task<List<ApplicationUserDto>?> GetUsers(
string? tenantId,
CancellationToken cancellation = default
);
Task<string?> GetUserNameAsync(string userId, CancellationToken cancellation = default);
Task<bool> IsInRoleAsync(string userId, string role, CancellationToken cancellation = default);
Task<bool> AuthorizeAsync(string userId, string policyName, CancellationToken cancellation = default);
Task<Result> DeleteUserAsync(string userId, CancellationToken cancellation = default);
Task<IDictionary<string, string?>> FetchUsers(string roleName, CancellationToken cancellation = default);
Task UpdateLiveStatus(string userId, bool isLive, CancellationToken cancellation = default);
Task<ApplicationUserDto?> GetApplicationUserDto(string userName, CancellationToken cancellation = default);
string GetUserName(string userId);
Task<List<ApplicationUserDto>?> GetUsers(string? tenantId, CancellationToken cancellation = default);
void RemoveApplicationUserCache(string userName);
}
4 changes: 2 additions & 2 deletions src/Application/Common/Models/OrgItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

public class OrgItem
{
public int? Id { get; set; }
public string? Id { get; set; }
public string? Area { get; set; }
public string? ImageUrl { get; set; }
public bool IsLoggedUser { get; set; }
public string? Name { get; set; }
public string? Office { get; set; }
public int? ParentId { get; set; }
public string? ParentId { get; set; }
public string? PositionName { get; set; }
public string? ProfileUrl { get; set; }
public string? Size { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions src/Application/Common/Security/PermissionModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public class PermissionModel
public string ClaimValue { get; set; } = "";
public bool Assigned { get; set; }

public int? RoleId { get; set; }
public int? UserId { get; set; }
public string? RoleId { get; set; }
public string? UserId { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Cfo.Cats.Application.Common.Security;


[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
public class RequestAuthorizeAttribute : Attribute
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/Application/Common/Security/ResetPasswordFormModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

public class ResetPasswordFormModel
{
public int? Id { get; set; }
public string? Id { get; set; }
public string? UserName { get; set; }
public string? DisplayName { get; set; }
public string? ProfilePictureDataUrl { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions src/Application/Common/Security/UserProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ public class UserProfile
{
public string? Provider { get; set; }
public string? SuperiorName { get; set; }
public int? SuperiorId { get; set; }
public string? SuperiorId { get; set; }
public string? ProfilePictureDataUrl { get; set; }
public string? DisplayName { get; set; }
public required string UserName { get; set; }
public required string Email { get; set; }
public string? PhoneNumber { get; set; }
public string? DefaultRole { get; set; }
public string[]? AssignedRoles { get; set; }
public int UserId { get; set; }
public required string UserId { get; set; } = Guid.NewGuid().ToString();
public bool IsActive { get; set; }
public string? TenantId { get; set; }
public string? TenantName { get; set; }
}
}
20 changes: 5 additions & 15 deletions src/Application/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,13 @@ public static class DependencyInjection
{
public static IServiceCollection AddApplication(this IServiceCollection services)
{
var assembly = Assembly.GetExecutingAssembly();

services.AddAutoMapper(config =>
{
config.AddMaps(assembly);
});

services.AddValidatorsFromAssembly(assembly);

services.AddAutoMapper(config => { config.AddMaps(Assembly.GetExecutingAssembly()); });
services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly());
services.AddMediatR(config =>
{
config.RegisterServicesFromAssembly(assembly);
config.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
config.NotificationPublisher = new ParallelNoWaitPublisher();
config.AddRequestPreProcessor(
typeof(IRequestPreProcessor<>),
typeof(ValidationPreProcessor<>)
);
config.AddRequestPreProcessor(typeof(IRequestPreProcessor<>), typeof(ValidationPreProcessor<>));
config.AddOpenBehavior(typeof(PerformanceBehaviour<,>));
config.AddOpenBehavior(typeof(UnhandledExceptionBehaviour<,>));
config.AddOpenBehavior(typeof(RequestExceptionProcessorBehavior<,>));
Expand All @@ -38,4 +28,4 @@ public static IServiceCollection AddApplication(this IServiceCollection services

return services;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
using Cfo.Cats.Application.Features.AuditTrails.Caching;
using Cfo.Cats.Application.Features.AuditTrails.DTOs;
using Cfo.Cats.Application.Features.AuditTrails.Specifications;
using Cfo.Cats.Application.SecurityConstants;
using DocumentFormat.OpenXml.Wordprocessing;

namespace Cfo.Cats.Application.Features.AuditTrails.Queries.PaginationQuery;

[RequestAuthorize(Roles = "Admin")]
[RequestAuthorize(Roles = RoleNames.SystemSupport)]
public class AuditTrailsWithPaginationQuery
: AuditTrailAdvancedFilter,
ICacheableRequest<PaginatedData<AuditTrailDto>>
Expand Down
2 changes: 0 additions & 2 deletions src/Application/Features/Candidates/DTOs/CandidateDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@ public Mapping()
options => options.MapFrom(candidate => candidate.LastName))
.ForMember(candidateDto => candidateDto.CurrentLocation,
options => options.MapFrom(candidate => candidate.CurrentLocation.Name))
.ForMember(candidateDto => candidateDto.EnrolmentStatus,
options => options.MapFrom(candidate => candidate.Participant!.EnrolmentStatus))
.ForMember(candidateDto => candidateDto.ExternalIdentifiers,
options => options.MapFrom(candidate => candidate.Identifiers.Select(p => p.IdentifierValue).ToArray()));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
using Cfo.Cats.Application.Common.Security;
using Cfo.Cats.Application.Features.Candidates.Caching;
using Cfo.Cats.Application.Features.Candidates.DTOs;
using Cfo.Cats.Application.SecurityConstants;

namespace Cfo.Cats.Application.Features.Candidates.Queries.Search;

[RequestAuthorize(Roles = "Admin, Basic")]
[RequestAuthorize(Policy = PolicyNames.AllowCandidateSearch)]
public class CandidateSearchQuery : ICacheableRequest<IEnumerable<CandidateDto>>
{
public required string ExternalIdentifier { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ public CandidateSearchQueryHandler(IApplicationDbContext dbContext, IMapper mapp
public async Task<IEnumerable<CandidateDto>> Handle(CandidateSearchQuery request, CancellationToken cancellationToken)
{
var query = from c in dbContext.Candidates
.Include(c => c.Participant)
where
c.LastName == request.LastName
c.LastName == request.LastName && c.DateOfBirth == request.DateOfBirth
|| c.Identifiers.Any(i => i.IdentifierValue == request.ExternalIdentifier)
|| c.DateOfBirth == request.DateOfBirth
select c;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Cfo.Cats.Application.Features.Documents.Caching;

public static class DocumentCacheKey
{
private static readonly TimeSpan RefreshInterval = TimeSpan.FromSeconds(30);
private static readonly TimeSpan RefreshInterval = TimeSpan.FromMinutes(10);
private static CancellationTokenSource tokenSource;

static DocumentCacheKey()
Expand All @@ -20,6 +20,11 @@ public static CancellationTokenSource SharedExpiryTokenSource()
return tokenSource;
}

public static MemoryCacheEntryOptions MemoryCacheEntryOptions =>
new MemoryCacheEntryOptions().AddExpirationToken(
new CancellationChangeToken(SharedExpiryTokenSource().Token)
);

public static void Refresh() => SharedExpiryTokenSource().Cancel();

public static string GetDocumentCacheKey(Guid key) => $"DocumentCacheKey,{key}";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using Cfo.Cats.Application.Common.Security;
using Cfo.Cats.Application.Features.Candidates.Caching;
using Cfo.Cats.Application.SecurityConstants;

namespace Cfo.Cats.Application.Features.Documents.Commands.Transistion;

public static class SubmitToProviderQa
{
[RequestAuthorize(Policy = PolicyNames.AllowEnrol)]
public class Command : ICacheInvalidatorRequest<Result>
{
public required string ParticipantId { get; set; }

public string CacheKey => CandidatesCacheKey.GetCacheKey(ParticipantId);

public CancellationTokenSource? SharedExpiryTokenSource => CandidatesCacheKey.SharedExpiryTokenSource();
}

public class Handler(IApplicationDbContext context) : IRequestHandler<Command, Result>
{
public async Task<Result> Handle(Command request, CancellationToken cancellationToken)
{
var participant = await context.Participants.FindAsync(request.ParticipantId);
participant!.TransitionTo(EnrolmentStatus.SubmittedToProviderStatus);
await context.SaveChangesAsync(cancellationToken);
// ReSharper disable once MethodHasAsyncOverload
return Result.Success();
}
}

}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using Cfo.Cats.Application.Common.Security;
using Cfo.Cats.Application.Features.Documents.Caching;
using Cfo.Cats.Application.SecurityConstants;

namespace Cfo.Cats.Application.Features.Documents.Commands.Upload;

[RequestAuthorize(Roles = "Admin, Basic")]
[RequestAuthorize(Policy = PolicyNames.AllowDocumentUpload)]
public class UploadDocumentCommand : ICacheInvalidatorRequest<Result<Guid>>
{
public string CacheKey { get; } = string.Empty;
Expand Down
Loading
Loading