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

Develop -> main #290

Merged
merged 6 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
"dotnet-cake"
],
"rollForward": false
},
"dotnet-outdated-tool": {
"version": "4.6.4",
"commands": [
"dotnet-outdated"
],
"rollForward": false
}
}
}
14 changes: 7 additions & 7 deletions src/Application/Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Humanizer.Core.uk" Version="2.14.1" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" Version="8.0.10" />
<PackageReference Include="Ardalis.Specification" Version="8.0.0" />
<PackageReference Include="Ardalis.Specification.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="ClosedXML" Version="0.104.0-preview2" />
<PackageReference Include="ClosedXML" Version="0.104.1" />
<PackageReference Include="AutoMapper" Version="13.0.1" />
<PackageReference Include="FluentValidation" Version="11.9.2" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.9.2" />
<PackageReference Include="FluentValidation" Version="11.10.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.10.0" />
<PackageReference Include="LazyCache" Version="2.4.0" />
<PackageReference Include="LazyCache.AspNetCore" Version="2.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.8" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.10" />
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="8.0.10" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.5" />
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.4.6" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Domain\Domain.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class Command : IRequest<Result>
public EscalationResponse? Response { get; set; }

public string Message { get; set; } = default!;

public bool IsMessageExternal { get; set; }
public UserProfile? CurrentUser { get; set; }

}
Expand All @@ -38,7 +40,7 @@ public async Task<Result> Handle(Command request, CancellationToken cancellation
return Result.Failure("Cannot find queue item");
}

entry.AddNote(request.Message);
entry.AddNote(request.Message, request.IsMessageExternal);

switch (request.Response)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Cfo.Cats.Application.Common.Security;
using Cfo.Cats.Application.Common.Security;
using Cfo.Cats.Application.Common.Validators;
using Cfo.Cats.Application.SecurityConstants;
using Cfo.Cats.Domain.Entities.Participants;
Expand All @@ -15,6 +15,7 @@ public class Command : IRequest<Result>
public bool? Accept { get; set; }

public string Message { get; set; } = default!;

public UserProfile? CurrentUser { get; set; }
}

Expand All @@ -31,7 +32,7 @@ public async Task<Result> Handle(Command request, CancellationToken cancellation
return Result.Failure("Cannot find queue item");
}

entry.AddNote(request.Message);
entry.AddNote(request.Message, isExternal: false);

if (request.Accept.GetValueOrDefault())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class Command : IRequest<Result>
public Qa2Response? Response { get; set; }

public string Message { get; set; } = default!;

public bool IsMessageExternal { get; set; }
public UserProfile? CurrentUser { get; set; }
}

Expand All @@ -39,7 +41,7 @@ public async Task<Result> Handle(Command request, CancellationToken cancellation
return Result.Failure("Cannot find queue item");
}

entry.AddNote(request.Message);
entry.AddNote(request.Message, request.IsMessageExternal);


switch (request.Response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Cfo.Cats.Domain.Entities.Participants;
using Cfo.Cats.Domain.ValueObjects;

namespace Cfo.Cats.Application.Features.QualityAssurance.DTOs
Expand All @@ -13,13 +14,14 @@ public class EnrolmentQaNoteDto
public required string Message { get; set; }
public required string CreatedBy { get; set; }
public required string TenantName { get; set; }
public required bool IsExternal { get; set; }

private class Mapper : Profile
{

public Mapper()
{
CreateMap<Note, EnrolmentQaNoteDto>()
CreateMap<EnrolmentQueueEntryNote, EnrolmentQaNoteDto>()
.ForMember(target => target.CreatedBy, options => options.MapFrom(source=>source.CreatedByUser.DisplayName))
.ForMember(target => target.Message, options => options.MapFrom(source => source.Message))
.ForMember(target => target.Created, options => options.MapFrom(source => source.Created))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,33 @@ public class Query : IRequest<Result<EnrolmentQaNoteDto[]>>
{
public string? ParticipantId { get;set; }

public bool IncludeInternalNotes { get; set; }

public UserProfile? CurentUser {get;set;}
}

public class Handler(IUnitOfWork unitOfWork, IMapper mapper) : IRequestHandler<Query, Result<EnrolmentQaNoteDto[]>>
public class Handler(
IUnitOfWork unitOfWork,
IMapper mapper) : IRequestHandler<Query, Result<EnrolmentQaNoteDto[]>>
{
public async Task<Result<EnrolmentQaNoteDto[]>> Handle(Query request, CancellationToken cancellationToken)
{
var pqa = await GetPqaNotes(request.ParticipantId!);
var qa1 = await GetQa1Notes(request.ParticipantId!);
var qa2 = await GetQa2Notes(request.ParticipantId!);
var es = await GetEscalationNotes(request.ParticipantId!);
var qa1 = await GetQa1Notes(request.ParticipantId!, request.IncludeInternalNotes);
var qa2 = await GetQa2Notes(request.ParticipantId!, request.IncludeInternalNotes);
var es = await GetEscalationNotes(request.ParticipantId!, request.IncludeInternalNotes);


return Result<EnrolmentQaNoteDto[]>.Success(pqa.Union(qa1).Union(qa2).Union(es).ToArray());

}

private async Task<EnrolmentQaNoteDto[]> GetEscalationNotes(string participantId)
private async Task<EnrolmentQaNoteDto[]> GetEscalationNotes(string participantId, bool includeInternalNotes)
{
var query1 = unitOfWork.DbContext.EnrolmentEscalationQueue
.AsNoTracking()
.Where(c => c.ParticipantId == participantId)
.SelectMany(c => c.Notes)
.SelectMany(c => c.Notes.Where(n => n.IsExternal || includeInternalNotes))
.ProjectTo<EnrolmentQaNoteDto>(mapper.ConfigurationProvider);


Expand All @@ -55,25 +59,25 @@ private async Task<EnrolmentQaNoteDto[]> GetPqaNotes(string participantId)
return results;
}

private async Task<EnrolmentQaNoteDto[]> GetQa1Notes(string participantId)
private async Task<EnrolmentQaNoteDto[]> GetQa1Notes(string participantId, bool includeInternalNotes)
{
var query1 = unitOfWork.DbContext.EnrolmentQa1Queue
.AsNoTracking()
.Where(c => c.ParticipantId == participantId)
.SelectMany(c => c.Notes)
.SelectMany(c => c.Notes.Where(n => n.IsExternal || includeInternalNotes))
.ProjectTo<EnrolmentQaNoteDto>(mapper.ConfigurationProvider);


var results = await query1.ToArrayAsync()!;
return results;
}

private async Task<EnrolmentQaNoteDto[]> GetQa2Notes(string participantId)
private async Task<EnrolmentQaNoteDto[]> GetQa2Notes(string participantId, bool includeInternalNotes)
{
var query1 = unitOfWork.DbContext.EnrolmentQa2Queue
.AsNoTracking()
.Where(c => c.ParticipantId == participantId)
.SelectMany(c => c.Notes)
.SelectMany(c => c.Notes.Where(n => n.IsExternal || includeInternalNotes))
.ProjectTo<EnrolmentQaNoteDto>(mapper.ConfigurationProvider);


Expand Down
2 changes: 2 additions & 0 deletions src/Application/SecurityConstants/SecurityPolicies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public static class SecurityPolicies

public const string Qa2 = nameof(Qa2);

public const string Internal = nameof(Internal);

public const string SeniorInternal = nameof(SeniorInternal);

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions src/Domain/Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ardalis.SmartEnum" Version="8.0.0" />
<PackageReference Include="MediatR" Version="12.4.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Ardalis.SmartEnum" Version="8.1.0" />
<PackageReference Include="MediatR" Version="12.4.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.10" />
</ItemGroup>

</Project>
11 changes: 6 additions & 5 deletions src/Domain/Entities/Participants/EnrolmentQueueEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace Cfo.Cats.Domain.Entities.Participants;

public abstract class EnrolmentQueueEntry : OwnerPropertyEntity<Guid>, IMustHaveTenant
{
private readonly List<Note> _notes = [];
private readonly List<EnrolmentQueueEntryNote> _notes = [];

public bool IsAccepted { get; protected set; }
public bool IsCompleted { get; protected set; }
Expand All @@ -32,22 +32,23 @@ protected EnrolmentQueueEntry(string participantId)
public virtual Participant? Participant { get; private set; }
public virtual Tenant? Tenant { get; private set; }

public IReadOnlyCollection<Note> Notes => _notes.AsReadOnly();
public IReadOnlyCollection<EnrolmentQueueEntryNote> Notes => _notes.AsReadOnly();

public abstract EnrolmentQueueEntry Accept();


public abstract EnrolmentQueueEntry Return();


public EnrolmentQueueEntry AddNote(string? message)
public EnrolmentQueueEntry AddNote(string? message, bool isExternal = false)
{
if (string.IsNullOrWhiteSpace(message) == false)
{
_notes.Add(new Note()
_notes.Add(new EnrolmentQueueEntryNote()
{
TenantId = TenantId,
Message = message
Message = message,
IsExternal = isExternal
});
}
return this;
Expand Down
8 changes: 8 additions & 0 deletions src/Domain/Entities/Participants/EnrolmentQueueEntryNote.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Cfo.Cats.Domain.ValueObjects;

namespace Cfo.Cats.Domain.Entities.Participants;

public class EnrolmentQueueEntryNote : Note
{
public bool IsExternal { get; set; }
}
12 changes: 12 additions & 0 deletions src/Infrastructure/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,18 @@ private static IServiceCollection AddAuthenticationService(this IServiceCollecti
policy.RequireClaim(ApplicationClaimTypes.AccountLocked, "False");
policy.RequireRole(RoleNames.SystemSupport, RoleNames.SMT, RoleNames.QAManager);
});

options.AddPolicy(SecurityPolicies.Internal, policy =>
{
policy.RequireAuthenticatedUser();
policy.RequireClaim(ApplicationClaimTypes.AccountLocked, "False");
policy.RequireRole(
RoleNames.SystemSupport,
RoleNames.SMT,
RoleNames.QAManager,
RoleNames.QAOfficer,
RoleNames.QASupportManager);
});
})
.AddAuthentication(options => {
options.DefaultScheme = IdentityConstants.ApplicationScheme;
Expand Down
30 changes: 15 additions & 15 deletions src/Infrastructure/Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,34 @@

<ItemGroup>
<PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="3.7.301" />
<PackageReference Include="AWSSDK.S3" Version="3.7.401.1" />
<PackageReference Include="AWSSDK.S3" Version="3.7.405" />
<PackageReference Include="EFCore.NamingConventions" Version="8.0.3" />
<PackageReference Include="GovukNotify" Version="7.2.0" />
<PackageReference Include="IPAddressRange" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8">
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8">
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.10">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.8" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="8.0.8" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.10" />
<PackageReference Include="Microsoft.Extensions.Identity.Core" Version="8.0.10" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Quartz" Version="3.13.0" />
<PackageReference Include="Quartz.AspNetCore" Version="3.13.0" />
<PackageReference Include="QuestPDF" Version="2024.7.2" />
<PackageReference Include="Sentry.Serilog" Version="4.10.2" />
<PackageReference Include="Serilog" Version="4.0.1" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.2" />
<PackageReference Include="QuestPDF" Version="2024.10.1" />
<PackageReference Include="Sentry.Serilog" Version="4.12.1" />
<PackageReference Include="Serilog" Version="4.0.2" />
<PackageReference Include="Serilog.AspNetCore" Version="8.0.3" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="ZiggyCreatures.FusionCache" Version="1.3.0" />
<PackageReference Include="ZiggyCreatures.FusionCache" Version="1.4.0" />
<PackageReference Include="Hmpps.Cfo.Matching.Core" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Cfo.Cats.Application.Common.Validators;
using Cfo.Cats.Application.Common.Validators;
using Cfo.Cats.Domain.Entities.Participants;
using Cfo.Cats.Infrastructure.Constants.Database;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
Expand Down Expand Up @@ -45,9 +45,8 @@ public void Configure(EntityTypeBuilder<EnrolmentPqaQueueEntry> builder)

note.Property(n => n.LastModifiedBy)
.HasMaxLength(DatabaseConstants.FieldLengths.GuidId);




note.Ignore(x => x.IsExternal);
});

builder.HasOne(t => t.Tenant)
Expand Down
Loading
Loading