Skip to content

Commit e7c2e8c

Browse files
authored
Merge pull request #555 from bcgov/yj
chore: listing process with biz lic
2 parents 0195d5a + 04939c1 commit e7c2e8c

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

server/StrDss.Service/RentalListingReportService.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
using StrDss.Service.EmailTemplates;
1616
using StrDss.Service.HttpClients;
1717
using System.Diagnostics;
18+
using System.Net;
19+
using System.Security.Cryptography;
1820
using System.Text;
1921

2022
namespace StrDss.Service
@@ -416,16 +418,19 @@ private async Task<DssRentalListing> CreateOrUpdateRentalListing(DssRentalListin
416418

417419
masterListing.EffectiveHostNm = CommonUtils.SanitizeAndUppercaseString(row.PropertyHostNm);
418420

419-
var needBusinessLicenseLink = await this.NeedBusinessLicenseLink(masterListing, physicalAddress);
421+
var managingOrgId = physicalAddress.ContainingOrganizationId.HasValue ?
422+
await _orgRepo.GetManagingOrgId(physicalAddress.ContainingOrganizationId.Value) : null;
423+
424+
var needBusinessLicenseLink = await NeedBusinessLicenseLink(masterListing, managingOrgId);
420425

421426
if (needBusinessLicenseLink)
422427
{
423-
if (!string.IsNullOrEmpty(masterListing.BusinessLicenceNo) && physicalAddress.ContainingOrganizationId.HasValue)
428+
if (!string.IsNullOrEmpty(masterListing.BusinessLicenceNo) && managingOrgId.HasValue)
424429
{
425430
var sanitizedBizLicNo = CommonUtils.SanitizeAndUppercaseString(masterListing.BusinessLicenceNo);
426431

427432
var (businessLicenceId, businessLicenceNo) = await _bizLicRepo.GetMatchingBusinessLicenseIdAndNo(
428-
physicalAddress.ContainingOrganizationId.Value,
433+
managingOrgId.Value,
429434
sanitizedBizLicNo
430435
);
431436

@@ -449,7 +454,7 @@ private async Task<DssRentalListing> CreateOrUpdateRentalListing(DssRentalListin
449454
return (true, masterListing);
450455
}
451456

452-
private async Task<bool> NeedBusinessLicenseLink(DssRentalListing masterListing, DssPhysicalAddress physicalAddress)
457+
private async Task<bool> NeedBusinessLicenseLink(DssRentalListing masterListing, long? managingOrgId)
453458
{
454459
// If there's no existing link, a link is needed
455460
if (masterListing.GoverningBusinessLicenceId == null)
@@ -463,11 +468,11 @@ private async Task<bool> NeedBusinessLicenseLink(DssRentalListing masterListing,
463468
return true;
464469

465470
// A de-link is needed if the listing has no jurisdiction
466-
if (!physicalAddress.ContainingOrganizationId.HasValue)
471+
if (!managingOrgId.HasValue)
467472
return true;
468473

469474
// A re-link is needed if the listing has been reassigned to a different jurisdiction
470-
if (physicalAddress.ContainingOrganizationId.Value != orgId)
475+
if (managingOrgId.Value != orgId)
471476
return true;
472477

473478
// Keep the overridden link if the business license has been changed

0 commit comments

Comments
 (0)