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-1053: Link mandatory objective to PRI on creation #441

Merged
merged 1 commit into from
Jan 29, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,7 @@ public async Task Handle(PRICreatedDomainEvent notification, CancellationToken c
tasks.ForEach(task => objective.AddTask(task));

pathwayPlan.AddObjective(objective);

notification.Entity.SetObjective(objective);
}
}
7 changes: 7 additions & 0 deletions src/Domain/Entities/PRIs/PRI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ private PRI()
public int CustodyLocationId { get; private set; }

public virtual Location CustodyLocation { get; private set; }
public Guid ObjectiveId { get; private set; }

public static PRI Create(string participantId, DateOnly expectedReleaseDate, int expectedReleaseRegionId, string createdBy, int custodyLocationId)
{
Expand Down Expand Up @@ -77,6 +78,12 @@ public PRI SetActualReleaseDate(DateOnly actualReleaseDate)
return this;
}

public PRI SetObjective(Objective objective)
{
ObjectiveId = objective.Id;
return this;
}

public PRI WithMeeting(
DateOnly attendedOn,
string? reasonCustodyDidNotAttendInPerson = null,
Expand Down
1 change: 1 addition & 0 deletions src/Domain/Entities/Participants/Objective.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class Objective : BaseAuditableEntity<Guid>
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
private Objective()
{
Id = Guid.CreateVersion7();
}
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.

Expand Down
1 change: 1 addition & 0 deletions src/Domain/Entities/Participants/ObjectiveTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class ObjectiveTask : BaseAuditableEntity<Guid>
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
private ObjectiveTask()
{
Id = Guid.CreateVersion7();
}
#pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public void Configure(EntityTypeBuilder<PathwayPlan> builder)

objective.HasKey(objective => objective.Id);

objective.Property(objective => objective.Id)
.ValueGeneratedNever();

objective.Property(objective => objective.CreatedBy)
.HasMaxLength(DatabaseConstants.FieldLengths.GuidId);

Expand Down Expand Up @@ -93,6 +96,9 @@ public void Configure(EntityTypeBuilder<PathwayPlan> builder)

task.HasKey(task => task.Id);

task.Property(task => task.Id)
.ValueGeneratedNever();

task.Property(task => task.CreatedBy)
.HasMaxLength(DatabaseConstants.FieldLengths.GuidId);

Expand Down
Loading