Skip to content

Commit

Permalink
Merge pull request #390 from bcgov/yj
Browse files Browse the repository at this point in the history
fix: TDR from listing
  • Loading branch information
ychung-mot authored Jun 17, 2024
2 parents c33369b + 31df728 commit 61618a9
Showing 1 changed file with 25 additions and 37 deletions.
62 changes: 25 additions & 37 deletions server/StrDss.Service/DelistingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ private async Task SendTakedownNoticesAsync(TakedownNoticesFromListingDto[] list
{
try
{
await SendTakedownNoticeFromListingEmail(listings, template);
await SendTakedownNoticeFromListing(listings, template);
}
catch (Exception ex)
{
Expand All @@ -356,7 +356,7 @@ private async Task SendTakedownNoticesAsync(TakedownNoticesFromListingDto[] list
}
}

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

Expand Down Expand Up @@ -551,45 +551,33 @@ private async Task SendTakedownRequestEmailsFromListingAsync(TakedownRequestsFro

private async Task SendTakedownRequestEmailFromListing(TakedownRequestsFromListingDto[] listings, TakedownRequestFromListing template)
{
var emailEntities = new List<DssEmailMessage>();
var listing = listings.First(x => x.RentalListingId == template.RentalListingId);

foreach (var listing in listings)
var emailEntity = new DssEmailMessage
{
var emailEntity = new DssEmailMessage
{
EmailMessageType = template.EmailMessageType,
MessageDeliveryDtm = DateTime.UtcNow,
MessageTemplateDsc = template.GetContent(),
IsHostContactedExternally = false,
LgPhoneNo = null,
UnreportedListingNo = listing.ListingId,
HostEmailAddressDsc = null,
LgEmailAddressDsc = null,
CcEmailAddressDsc = string.Join("; ", template.Cc),
UnreportedListingUrl = listing.Url,
LgStrBylawUrl = null,
InitiatingUserIdentityId = _currentUser.Id,
AffectedByUserIdentityId = null,
InvolvedInOrganizationId = listing.ProvidingPlatformId,
RequestingOrganizationId = _currentUser.OrganizationId,
IsWithStandardDetail = listing.IsWithStandardDetail,
CustomDetailTxt = listing.CustomDetailTxt,
ConcernedWithRentalListingId = listing.RentalListingId,
};

emailEntities.Add(emailEntity);

await _emailRepo.AddEmailMessage(emailEntity);
}

await _emailRepo.AddEmailMessage(emailEntities.First());
EmailMessageType = template.EmailMessageType,
MessageDeliveryDtm = DateTime.UtcNow,
MessageTemplateDsc = template.GetContent(),
IsHostContactedExternally = false,
LgPhoneNo = null,
UnreportedListingNo = listing.ListingId,
HostEmailAddressDsc = null,
LgEmailAddressDsc = null,
CcEmailAddressDsc = string.Join("; ", template.Cc),
UnreportedListingUrl = listing.Url,
LgStrBylawUrl = null,
InitiatingUserIdentityId = _currentUser.Id,
AffectedByUserIdentityId = null,
InvolvedInOrganizationId = listing.ProvidingPlatformId,
RequestingOrganizationId = _currentUser.OrganizationId,
IsWithStandardDetail = listing.IsWithStandardDetail,
CustomDetailTxt = listing.CustomDetailTxt,
ConcernedWithRentalListingId = listing.RentalListingId,
};

var messageNo = await template.SendEmail();
await _emailRepo.AddEmailMessage(emailEntity);

foreach (var emailEntity in emailEntities)
{
emailEntity.ExternalMessageNo = messageNo;
}
emailEntity.ExternalMessageNo = await template.SendEmail();

_unitOfWork.Commit();
}
Expand Down

0 comments on commit 61618a9

Please sign in to comment.