Skip to content

Commit

Permalink
Merge pull request #331 from bcgov/yj
Browse files Browse the repository at this point in the history
fix: bug fix for file upload
  • Loading branch information
ychung-mot authored May 30, 2024
2 parents 3718a2b + ca73b50 commit 8bf7396
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
11 changes: 10 additions & 1 deletion server/StrDss.Data/Repositories/UploadDeliveryRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public interface IUploadDeliveryRepository
Task AddUploadDeliveryAsync(DssUploadDelivery upload);
Task<List<DssUploadDelivery>> GetRentalReportUploadsToProcessAsync();
Task<DssUploadDelivery?> GetRentalListingErrorLines(long uploadId);
Task<DssUploadLine?> GetUploadLineAsync(long uploadId, string orgCd, string listingId);
}

public class UploadDeliveryRepository : RepositoryBase<DssUploadDelivery>, IUploadDeliveryRepository
Expand All @@ -36,7 +37,7 @@ public async Task<bool> IsDuplicateRentalReportUploadAsnyc(DateOnly periodYm, lo
public async Task<List<DssUploadDelivery>> GetRentalReportUploadsToProcessAsync()
{
return await _dbSet
.Include(x => x.DssUploadLines.Where(line => !line.IsProcessed))
//.Include(x => x.DssUploadLines.Where(line => !line.IsProcessed))
.Include(x => x.ProvidingOrganization)
.Where(x => x.DssUploadLines.Any(line => !line.IsProcessed))
.OrderBy(x => x.ProvidingOrganizationId)
Expand All @@ -45,6 +46,14 @@ public async Task<List<DssUploadDelivery>> GetRentalReportUploadsToProcessAsync(
.ToListAsync();
}

public async Task<DssUploadLine?> GetUploadLineAsync(long uploadId, string orgCd, string listingId)
{
return await _dbContext.DssUploadLines.FirstOrDefaultAsync(x =>
x.IncludingUploadDeliveryId == uploadId &&
x.SourceOrganizationCd == orgCd &&
x.SourceRecordNo == listingId);
}

public async Task<DssUploadDelivery?> GetRentalListingErrorLines(long uploadId)
{
//todo: data control
Expand Down
2 changes: 1 addition & 1 deletion server/StrDss.Service/RentalListingReportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ private async Task ProcessRentalReportUploadAsync(DssUploadDelivery upload)
while (csv.Read())
{
var row = csv.GetRecord<RentalListingRowUntyped>(); //it has been parsed once, so no exception expected.
var uploadLine = upload.DssUploadLines.FirstOrDefault(x => x.SourceOrganizationCd == row.OrgCd && x.SourceRecordNo == row.ListingId);
var uploadLine = await _uploadRepo.GetUploadLineAsync(upload.UploadDeliveryId, row.OrgCd, row.ListingId);

if (uploadLine == null)
{
Expand Down
9 changes: 6 additions & 3 deletions server/StrDss.Service/RentalListingReportValidationRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,24 +82,27 @@ public static void LoadReportValidationRules(List<FieldValidationRule> rules)
{
EntityName = Entities.RentalListingRowUntyped,
FieldName = RentalListingReportFields.BedroomsQty,
FieldType = FieldTypes.Decimal,
FieldType = FieldTypes.String,
Required = false,
RegexInfo = RegexDefs.GetRegexInfo(RegexDefs.Quantity)
});

rules.Add(new FieldValidationRule
{
EntityName = Entities.RentalListingRowUntyped,
FieldName = RentalListingReportFields.NightsBookedQty,
FieldType = FieldTypes.Decimal,
FieldType = FieldTypes.String,
Required = false,
RegexInfo = RegexDefs.GetRegexInfo(RegexDefs.Quantity)
});

rules.Add(new FieldValidationRule
{
EntityName = Entities.RentalListingRowUntyped,
FieldName = RentalListingReportFields.ReservationsQty,
FieldType = FieldTypes.Decimal,
FieldType = FieldTypes.String,
Required = false,
RegexInfo = RegexDefs.GetRegexInfo(RegexDefs.Quantity)
});

rules.Add(new FieldValidationRule
Expand Down

0 comments on commit 8bf7396

Please sign in to comment.