15
15
using StrDss . Service . EmailTemplates ;
16
16
using StrDss . Service . HttpClients ;
17
17
using System . Diagnostics ;
18
+ using System . Net ;
19
+ using System . Security . Cryptography ;
18
20
using System . Text ;
19
21
20
22
namespace StrDss . Service
@@ -416,16 +418,19 @@ private async Task<DssRentalListing> CreateOrUpdateRentalListing(DssRentalListin
416
418
417
419
masterListing . EffectiveHostNm = CommonUtils . SanitizeAndUppercaseString ( row . PropertyHostNm ) ;
418
420
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 ) ;
420
425
421
426
if ( needBusinessLicenseLink )
422
427
{
423
- if ( ! string . IsNullOrEmpty ( masterListing . BusinessLicenceNo ) && physicalAddress . ContainingOrganizationId . HasValue )
428
+ if ( ! string . IsNullOrEmpty ( masterListing . BusinessLicenceNo ) && managingOrgId . HasValue )
424
429
{
425
430
var sanitizedBizLicNo = CommonUtils . SanitizeAndUppercaseString ( masterListing . BusinessLicenceNo ) ;
426
431
427
432
var ( businessLicenceId , businessLicenceNo ) = await _bizLicRepo . GetMatchingBusinessLicenseIdAndNo (
428
- physicalAddress . ContainingOrganizationId . Value ,
433
+ managingOrgId . Value ,
429
434
sanitizedBizLicNo
430
435
) ;
431
436
@@ -449,7 +454,7 @@ private async Task<DssRentalListing> CreateOrUpdateRentalListing(DssRentalListin
449
454
return ( true , masterListing ) ;
450
455
}
451
456
452
- private async Task < bool > NeedBusinessLicenseLink ( DssRentalListing masterListing , DssPhysicalAddress physicalAddress )
457
+ private async Task < bool > NeedBusinessLicenseLink ( DssRentalListing masterListing , long ? managingOrgId )
453
458
{
454
459
// If there's no existing link, a link is needed
455
460
if ( masterListing . GoverningBusinessLicenceId == null )
@@ -463,11 +468,11 @@ private async Task<bool> NeedBusinessLicenseLink(DssRentalListing masterListing,
463
468
return true ;
464
469
465
470
// A de-link is needed if the listing has no jurisdiction
466
- if ( ! physicalAddress . ContainingOrganizationId . HasValue )
471
+ if ( ! managingOrgId . HasValue )
467
472
return true ;
468
473
469
474
// 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 )
471
476
return true ;
472
477
473
478
// Keep the overridden link if the business license has been changed
0 commit comments