Skip to content

Commit

Permalink
review updates
Browse files Browse the repository at this point in the history
  • Loading branch information
vks333 authored and carlsixsmith-moj committed Sep 16, 2024
1 parent 437a7e4 commit 9f47b5e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/Application/Features/Participants/DTOs/ParticipantDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ public class ParticipantDto
public string? MiddleName { get; set; }
public string? LastName { get; set; }
public DateOnly? DateOfBirth { get; set; }
public DateTime? Due { get; set; }
public int? DueInDays { get; set; }
public DateTime? RiskDue { get; set; }
public int? RiskDueInDays { get; set; }

[Description("Enrolment Status")]
public EnrolmentStatus? EnrolmentStatus { get; set; }
Expand Down Expand Up @@ -62,8 +62,8 @@ public Mapping()
.ForMember(target => target.ExternalIdentifiers, options => options.MapFrom(s => s.ExternalIdentifiers.ToArray()))
#nullable disable
.ForMember(target => target.SupportWorker, options => options.MapFrom(source => source.Owner.DisplayName))
.ForMember(dest => dest.Due, opt => opt.MapFrom(src => src.RiskDue))
.ForMember(dest => dest.DueInDays, opt => opt.MapFrom(src => src.RiskDueInDays()));
.ForMember(dest => dest.RiskDue, opt => opt.MapFrom(src => src.RiskDue))
.ForMember(dest => dest.RiskDueInDays, opt => opt.MapFrom(src => src.RiskDueInDays()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public async Task Handle(ConsentCreatedDomainEvent notification, CancellationTok
.Where(p => p.Id == notification.ParticipantId)
.FirstOrDefaultAsync(cancellationToken);

if (participant is not null && participant.Consents.Count == 1)
if (participant is { Consents.Count: 1 })
{
//Only on first Consent submit
participant.SetRiskDue(notification.ConsentDate.AddDays(14));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ public async Task Handle(ParticipantRegistrationDetailsChangedDomainEvent notifi
{
var participant = await unitOfWork.DbContext.Participants
.Where(p => p.Id == notification.Item.Id)
.FirstOrDefaultAsync(cancellationToken);
.FirstOrDefaultAsync(cancellationToken) ?? throw new NotFoundException("Participant", notification.Item.Id);

var risk = await unitOfWork.DbContext.Risks
.Where(r => r.ParticipantId == notification.Item.Id)
.FirstOrDefaultAsync(cancellationToken);

if (participant is not null &&
risk is not null &&
participant.RiskDue!.HasValue &&
participant.RiskDue!.Value > DateTime.Today)
if (risk is not null && participant.RiskDue > DateTime.Today)
{
//Only applicable if Risk information exists
//Set Risk Due date to today, only if it is later than today
Expand Down

0 comments on commit 9f47b5e

Please sign in to comment.