Skip to content

Commit

Permalink
Remove redundant MQ type on TestData
Browse files Browse the repository at this point in the history
  • Loading branch information
gunndabad committed Aug 20, 2024
1 parent ced2453 commit 2a7953a
Showing 1 changed file with 9 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public class CreatePersonBuilder
private bool? _hasNationalInsuranceNumber;
private string? _nationalInsuranceNumber;
private readonly List<Qualification> _qualifications = new();
private readonly List<MandatoryQualificationInfo> _mandatoryQualifications = new();
private readonly List<QtsRegistration> _qtsRegistrations = new();
private readonly List<Sanction> _sanctions = [];
private readonly List<CreatePersonMandatoryQualificationBuilder> _mqBuilders = [];
Expand Down Expand Up @@ -710,7 +709,7 @@ public CreatePersonMandatoryQualificationBuilder WithImportedByDqtUser(EventMode
return this;
}

internal async Task<MandatoryQualificationInfo> Execute(CreatePersonBuilder createPersonBuilder, TestData testData)
internal async Task<MandatoryQualification> Execute(CreatePersonBuilder createPersonBuilder, TestData testData)
{
var personId = createPersonBuilder.PersonId;

Expand All @@ -721,13 +720,13 @@ internal async Task<MandatoryQualificationInfo> Execute(CreatePersonBuilder crea
var endDate = _endDate.ValueOr(status == MandatoryQualificationStatus.Passed ? testData.GenerateDate(min: (startDate ?? new DateOnly(2000, 1, 1)).AddYears(1)) : null);
var createdUtc = _createdUtc.ValueOr(testData.Clock.UtcNow);

await testData.WithDbContext(async dbContext =>
return await testData.WithDbContext(async dbContext =>
{
var provider = providerId.HasValue ?
await dbContext.MandatoryQualificationProviders.SingleAsync(p => p.MandatoryQualificationProviderId == providerId) :
null;

dbContext.MandatoryQualifications.Add(new MandatoryQualification()
var mq = new MandatoryQualification()
{
QualificationId = QualificationId,
CreatedOn = testData.Clock.UtcNow,
Expand All @@ -740,7 +739,9 @@ await dbContext.MandatoryQualificationProviders.SingleAsync(p => p.MandatoryQual
EndDate = endDate,
DqtSpecialismId = _dqtSpecialismId.ValueOr((Guid?)null),
DqtMqEstablishmentId = _mqEstablishmentId.ValueOr((Guid?)null)
});
};

dbContext.MandatoryQualifications.Add(mq);

if (_importedByUser.HasValue)
{
Expand Down Expand Up @@ -799,18 +800,9 @@ await dbContext.MandatoryQualificationProviders.SingleAsync(p => p.MandatoryQual
}

await dbContext.SaveChangesAsync();
});

var mqInfo = new MandatoryQualificationInfo(
QualificationId,
providerId,
specialism,
status,
startDate,
endDate
);

return mqInfo;
return mq;
});
}
}

Expand All @@ -834,7 +826,7 @@ public record CreatePersonResult
public required DateOnly? QtsDate { get; init; }
public required DateOnly? EytsDate { get; init; }
public required IReadOnlyCollection<Sanction> Sanctions { get; init; }
public required IReadOnlyCollection<MandatoryQualificationInfo> MandatoryQualifications { get; init; }
public required IReadOnlyCollection<MandatoryQualification> MandatoryQualifications { get; init; }
public required IReadOnlyCollection<Induction> Inductions { get; init; }
public required IReadOnlyCollection<InductionPeriod> InductionPeriods { get; init; }
}
Expand All @@ -844,14 +836,6 @@ public record InductionPeriod(Guid InductionId, DateOnly? startDate, DateOnly? e

public record Sanction(Guid SanctionId, string SanctionCode, DateOnly? StartDate, DateOnly? EndDate, DateOnly? ReviewDate, bool Spent, string? Details, string? DetailsLink, bool IsActive);

public record MandatoryQualificationInfo(
Guid QualificationId,
Guid? ProviderId,
MandatoryQualificationSpecialism? Specialism,
MandatoryQualificationStatus? Status,
DateOnly? StartDate,
DateOnly? EndDate);

public record QtsRegistration(DateOnly? QtsDate, string? TeacherStatusValue, DateTime? CreatedOn, DateOnly? EytsDate, string? EytsStatusValue);

public record Qualification(
Expand Down

0 comments on commit 2a7953a

Please sign in to comment.