Skip to content

Commit

Permalink
Merge pull request #418 from bcgov/yj
Browse files Browse the repository at this point in the history
Yj
  • Loading branch information
ychung-mot authored Jun 20, 2024
2 parents 69202a4 + 97162dc commit b099992
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public async Task<ActionResult> CreateRentalLisingReport([FromForm] RentalListin

if (errors.Count > 0)
{
return ValidationUtils.GetValidationErrorResult(errors, ControllerContext);
return ValidationUtils.GetValidationErrorResult(errors, ControllerContext, "One or more validation errors occurred in uploaded file.");
}

return Ok();
Expand Down
4 changes: 2 additions & 2 deletions server/StrDss.Api/ValidationUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace StrDss.Api
{
public static class ValidationUtils
{
public static UnprocessableEntityObjectResult GetValidationErrorResult(Dictionary<string, List<string>> messages, ActionContext context)
public static UnprocessableEntityObjectResult GetValidationErrorResult(Dictionary<string, List<string>> messages, ActionContext context, string title = "")
{
var errors = new Dictionary<string, string[]>();

Expand All @@ -16,7 +16,7 @@ public static UnprocessableEntityObjectResult GetValidationErrorResult(Dictionar
var problem = new ValidationProblemDetails(errors)
{
Type = "https://strdss.bc.gov.ca/model-validation-error",
Title = "One or more validation errors occurred.",
Title = title == "" ? "One or more validation errors occurred." : title,
Status = StatusCodes.Status422UnprocessableEntity,
Detail = "Please refer to the errors property for additional details",
Instance = context.HttpContext.Request.Path
Expand Down
14 changes: 7 additions & 7 deletions server/StrDss.Service/DelistingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ public async Task<Dictionary<string, List<string>>> CreateTakedownNoticesFromLis
return errors;
}

await SendTakedownNoticesAsync(listings, templates, errors);
await SendTakedownNoticeEmailsFromListingAsync(listings, templates, errors);

return errors;
}
Expand Down Expand Up @@ -340,13 +340,13 @@ private TakedownNoticeFromListing CreateTakedownNoticeTemplate(TakedownNoticesFr
Info = $"{rentalListing.OrganizationCd}-{rentalListing.PlatformListingNo}"
};
}
private async Task SendTakedownNoticesAsync(TakedownNoticesFromListingDto[] listings, List<TakedownNoticeFromListing> templates, Dictionary<string, List<string>> errors)
private async Task SendTakedownNoticeEmailsFromListingAsync(TakedownNoticesFromListingDto[] listings, List<TakedownNoticeFromListing> templates, Dictionary<string, List<string>> errors)
{
foreach (var template in templates)
{
try
{
await SendTakedownNoticeFromListing(listings, template);
await SendTakedownNoticeEmailFromListingAsync(listings, template);
}
catch (Exception ex)
{
Expand All @@ -356,7 +356,7 @@ private async Task SendTakedownNoticesAsync(TakedownNoticesFromListingDto[] list
}
}

private async Task SendTakedownNoticeFromListing(TakedownNoticesFromListingDto[] listings, TakedownNoticeFromListing template)
private async Task SendTakedownNoticeEmailFromListingAsync(TakedownNoticesFromListingDto[] listings, TakedownNoticeFromListing template)
{
var listing = listings.First(x => x.RentalListingId == template.RentalListingId);

Expand All @@ -377,6 +377,7 @@ private async Task SendTakedownNoticeFromListing(TakedownNoticesFromListingDto[]
InitiatingUserIdentityId = _currentUser.Id,
AffectedByUserIdentityId = null,
InvolvedInOrganizationId = listing.ProvidingPlatformId,
ConcernedWithRentalListingId = listing.RentalListingId,
};

await _emailRepo.AddEmailMessage(emailEntity);
Expand Down Expand Up @@ -437,7 +438,6 @@ private async Task SendTakedownNoticeFromListing(TakedownNoticesFromListingDto[]
});
}


public async Task<Dictionary<string, List<string>>> CreateTakedownRequestsFromListingAsync(TakedownRequestsFromListingDto[] listings)
{
var errors = new Dictionary<string, List<string>>();
Expand Down Expand Up @@ -539,7 +539,7 @@ private async Task SendTakedownRequestEmailsFromListingAsync(TakedownRequestsFro
{
try
{
await SendTakedownRequestEmailFromListing(listings, template);
await SendTakedownRequestEmailFromListingAsync(listings, template);
}
catch (Exception ex)
{
Expand All @@ -549,7 +549,7 @@ private async Task SendTakedownRequestEmailsFromListingAsync(TakedownRequestsFro
}
}

private async Task SendTakedownRequestEmailFromListing(TakedownRequestsFromListingDto[] listings, TakedownRequestFromListing template)
private async Task SendTakedownRequestEmailFromListingAsync(TakedownRequestsFromListingDto[] listings, TakedownRequestFromListing template)
{
var listing = listings.First(x => x.RentalListingId == template.RentalListingId);

Expand Down

0 comments on commit b099992

Please sign in to comment.