Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKevJoy committed Jan 15, 2025
1 parent f33c006 commit d7d3772
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.ComponentModel.Design;
using System.Globalization;
using System.Text;
using CsvHelper;
Expand Down Expand Up @@ -134,26 +135,26 @@ public async Task<InductionImportResult> ImportAsync(StreamReader csvReaderStrea
};
rowTransaction.AppendQuery(queryInductionPeriod);
}
else
{
inductionPeriodId = lookupData.InductionPeriod.dfeta_inductionperiodId;
var updateInduction = new UpdateInductionTransactionalQuery()
{
InductionId = inductionId!.Value,
CompletionDate = DateTime.ParseExact(row.PassedDate, DATE_FORMAT, CultureInfo.InvariantCulture, DateTimeStyles.None),
InductionStatus = lookupData.Induction!.dfeta_InductionStatus!.Value
};
rowTransaction.AppendQuery(updateInduction);

var updateInductionPeriodQuery = new UpdateInductionPeriodTransactionalQuery()
{
InductionPeriodId = inductionPeriodId!.Value,
AppropriateBodyId = lookupData.OrganisationId,
InductionStartDate = lookupData.InductionPeriod.dfeta_StartDate,
InductionEndDate = DateTime.ParseExact(row.PassedDate, DATE_FORMAT, CultureInfo.InvariantCulture, DateTimeStyles.None),
};
rowTransaction.AppendQuery(updateInductionPeriodQuery);
}
//else
//{
// inductionPeriodId = lookupData.InductionPeriod.dfeta_inductionperiodId;
// var updateInduction = new UpdateInductionTransactionalQuery()
// {
// InductionId = inductionId!.Value,
// CompletionDate = DateTime.ParseExact(row.PassedDate, DATE_FORMAT, CultureInfo.InvariantCulture, DateTimeStyles.None),
// InductionStatus = lookupData.Induction!.dfeta_InductionStatus!.Value
// };
// rowTransaction.AppendQuery(updateInduction);

// var updateInductionPeriodQuery = new UpdateInductionPeriodTransactionalQuery()
// {
// InductionPeriodId = inductionPeriodId!.Value,
// AppropriateBodyId = lookupData.OrganisationId,
// InductionStartDate = lookupData.InductionPeriod.dfeta_StartDate,
// InductionEndDate = DateTime.ParseExact(row.PassedDate, DATE_FORMAT, CultureInfo.InvariantCulture, DateTimeStyles.None),
// };
// rowTransaction.AppendQuery(updateInductionPeriodQuery);
//}

//soft validation errors can be appended to the IntegrationTransactionRecord Failure message
foreach (var validationMessage in validationFailures.ValidationFailures)
Expand Down Expand Up @@ -259,15 +260,19 @@ public async Task<InductionImportLookupData> GetLookupDataAsync(EwcWalesInductio
inductionMatchStatus = indStatus;
induction = ind?.Induction;

if (ind?.InductionPeriods?.Length == 1)
{
inductionPeriodMatchStatus = InductionPeriodLookupResult.OneMatch;
inductionPeriod = ind.InductionPeriods.First();
}
else if (ind?.InductionPeriods?.Length > 1)
if (ind?.InductionPeriods?.Length > 0)
{
inductionPeriodMatchStatus = InductionPeriodLookupResult.MultipleMatchesFound;
inductionPeriod = null;
var periods = ind?.InductionPeriods.Where(x => !x.dfeta_EndDate.HasValue).ToList();
if (periods?.Count() == 1)
{
inductionPeriodMatchStatus = InductionPeriodLookupResult.OneMatch;
inductionPeriod = periods.First();
}
else if(periods?.Count() > 1)
{
inductionPeriodMatchStatus = InductionPeriodLookupResult.MultipleMatchesFound;
inductionPeriod = null;
}
}

hasActiveAlerts = _dbContext.Alerts.Where(x => x.PersonId == contact.Id && x.IsOpen).Count() > 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.ComponentModel.Design;
using System.Globalization;
using System.Text;
using CsvHelper;
Expand Down Expand Up @@ -134,26 +135,26 @@ public async Task<InductionImportResult> ImportAsync(StreamReader csvReaderStrea
};
rowTransaction.AppendQuery(queryInductionPeriod);
}
else
{
inductionPeriodId = lookupData.InductionPeriod.dfeta_inductionperiodId;
var updateInduction = new UpdateInductionTransactionalQuery()
{
InductionId = inductionId!.Value,
CompletionDate = DateTime.ParseExact(row.PassedDate, DATE_FORMAT, CultureInfo.InvariantCulture, DateTimeStyles.None),
InductionStatus = lookupData.Induction!.dfeta_InductionStatus!.Value
};
rowTransaction.AppendQuery(updateInduction);

var updateInductionPeriodQuery = new UpdateInductionPeriodTransactionalQuery()
{
InductionPeriodId = inductionPeriodId!.Value,
AppropriateBodyId = lookupData.OrganisationId,
InductionStartDate = lookupData.InductionPeriod.dfeta_StartDate,
InductionEndDate = DateTime.ParseExact(row.PassedDate, DATE_FORMAT, CultureInfo.InvariantCulture, DateTimeStyles.None),
};
rowTransaction.AppendQuery(updateInductionPeriodQuery);
}
//else
//{
// inductionPeriodId = lookupData.InductionPeriod.dfeta_inductionperiodId;
// var updateInduction = new UpdateInductionTransactionalQuery()
// {
// InductionId = inductionId!.Value,
// CompletionDate = DateTime.ParseExact(row.PassedDate, DATE_FORMAT, CultureInfo.InvariantCulture, DateTimeStyles.None),
// InductionStatus = lookupData.Induction!.dfeta_InductionStatus!.Value
// };
// rowTransaction.AppendQuery(updateInduction);

// var updateInductionPeriodQuery = new UpdateInductionPeriodTransactionalQuery()
// {
// InductionPeriodId = inductionPeriodId!.Value,
// AppropriateBodyId = lookupData.OrganisationId,
// InductionStartDate = lookupData.InductionPeriod.dfeta_StartDate,
// InductionEndDate = DateTime.ParseExact(row.PassedDate, DATE_FORMAT, CultureInfo.InvariantCulture, DateTimeStyles.None),
// };
// rowTransaction.AppendQuery(updateInductionPeriodQuery);
//}

//soft validation errors can be appended to the IntegrationTransactionRecord Failure message
foreach (var validationMessage in validationFailures.ValidationFailures)
Expand Down Expand Up @@ -259,15 +260,19 @@ public async Task<InductionImportLookupData> GetLookupDataAsync(EwcWalesInductio
inductionMatchStatus = indStatus;
induction = ind?.Induction;

if (ind?.InductionPeriods?.Length == 1)
{
inductionPeriodMatchStatus = InductionPeriodLookupResult.OneMatch;
inductionPeriod = ind.InductionPeriods.First();
}
else if (ind?.InductionPeriods?.Length > 1)
if (ind?.InductionPeriods?.Length > 0)
{
inductionPeriodMatchStatus = InductionPeriodLookupResult.MultipleMatchesFound;
inductionPeriod = null;
var periods = ind?.InductionPeriods.Where(x => !x.dfeta_EndDate.HasValue).ToList();
if (periods?.Count() == 1)
{
inductionPeriodMatchStatus = InductionPeriodLookupResult.OneMatch;
inductionPeriod = periods.First();
}
else if(periods?.Count() > 1)
{
inductionPeriodMatchStatus = InductionPeriodLookupResult.MultipleMatchesFound;
inductionPeriod = null;
}
}

hasActiveAlerts = _dbContext.Alerts.Where(x => x.PersonId == contact.Id && x.IsOpen).Count() > 0;
Expand Down

0 comments on commit d7d3772

Please sign in to comment.