Skip to content

Commit

Permalink
Merge pull request #802 from bcgov/yj
Browse files Browse the repository at this point in the history
Yj
  • Loading branch information
ychung-mot authored Nov 20, 2024
2 parents 3397129 + 8590b34 commit b0a06e4
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 0 deletions.
9 changes: 9 additions & 0 deletions server/StrDss.Api/Controllers/RentalListingsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,15 @@ public async Task<ActionResult> GetGroupedRentalListingsCount(string? all, strin
return Ok(count);
}

[ApiAuthorize(Permissions.ListingRead)]
[HttpGet("host/count")]
public async Task<ActionResult> CountHostListingsAsync(string hostName)
{
var count = await _listingService.CountHostListingsAsync(hostName);

return Ok(count);
}

[ApiAuthorize(Permissions.ListingRead)]
[HttpGet("{listingId}")]
public async Task<ActionResult> GetRentalListing(long listingId)
Expand Down
1 change: 1 addition & 0 deletions server/StrDss.Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public static class JurisdictionFields
public const string IsPrincipalResidenceRequired = "IsPrincipalResidenceRequired";
public const string IsStrProhibited = "IsStrProhibited";
public const string IsBusinessLicenceRequired = "IsBusinessLicenceRequired";
public const string IsStraaExempt = "IsStraaExempt";
public const string EconomicRegionDsc = "EconomicRegionDsc";
}

Expand Down
2 changes: 2 additions & 0 deletions server/StrDss.Data/Repositories/OrganizationRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ public async Task<OrganizationDto> GetOrganizationByOrgCdAsync(string orgCd)
{
var point = new Point(longitude, latitude) { SRID = 4326 };

// todo: add is_straa_exempt
var strRequirement = await _dbContext.DssOrganizations
.FromSqlRaw(@"
SELECT p.organization_nm, c.is_principal_residence_required, c.is_business_licence_required, c.is_str_prohibited
Expand All @@ -186,6 +187,7 @@ public async Task<OrganizationDto> GetOrganizationByOrgCdAsync(string orgCd)
IsPrincipalResidenceRequired = o.IsPrincipalResidenceRequired,
IsBusinessLicenceRequired = o.IsBusinessLicenceRequired,
IsStrProhibited = o.IsStrProhibited,
// todo: IsStraaExempt = o.IsStraaExempt
})
.OrderBy(o => o.OrganizationNm)
.FirstOrDefaultAsync();
Expand Down
12 changes: 12 additions & 0 deletions server/StrDss.Data/Repositories/RentalListingRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Task<PagedDto<RentalListingGroupDto>> GetGroupedRentalListings(string? all, stri
bool? prRequirement, bool? blRequirement, long? lgId, string[] statusArray, bool? reassigned, bool? takedownComplete, int pageSize, int pageNumber, string orderBy, string direction);
Task<int> GetGroupedRentalListingsCount(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence,
bool? prRequirement, bool? blRequirement, long? lgId, string[] statusArray, bool? reassigned, bool? takedownComplete);
Task<int> CountHostListingsAsync(string hostName);
Task<RentalListingViewDto?> GetRentalListing(long rentaListingId, bool loadHistory = true);
Task<RentalListingForTakedownDto?> GetRentalListingForTakedownAction(long rentlListingId, bool includeHostEmails);
Task<List<long>> GetRentalListingIdsToExport();
Expand Down Expand Up @@ -160,6 +161,17 @@ public async Task<int> GetGroupedRentalListingsCount(string? all, string? addres

return count;
}
public async Task<int> CountHostListingsAsync(string hostName)
{
var query = _dbSet.AsNoTracking();

if (_currentUser.OrganizationType == OrganizationTypes.LG)
{
query = query.Where(x => x.ManagingOrganizationId == _currentUser.OrganizationId);
}

return await query.CountAsync(x => x.EffectiveHostNm == hostName);
}

private static void ApplyFilters(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence,
bool? prRequirement, bool? blRequirement, long? lgId, string[] statusArray, bool? reassigned, bool? takedownComplete, ref IQueryable<DssRentalListingVw> query)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class JurisdictionUpdateDto
public bool? IsStrProhibited { get; set; }
public bool? IsBusinessLicenceRequired { get; set; }
public string? EconomicRegionDsc { get; set; }
public bool? IsStraaExempt { get; set; }
public DateTime UpdDtm { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class JurisdictionsViewDto
public bool? IsPrincipalResidenceRequired { get; set; }
public bool? IsStrProhibited { get; set; }
public bool? IsBusinessLicenceRequired { get; set; }
public bool? IsStraaExempt { get; set; }
public string? EconomicRegionDsc { get; set; }
public DateTime UpdDtm { get; set; }
}
Expand Down
1 change: 1 addition & 0 deletions server/StrDss.Model/OrganizationDtos/OrganizationDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class OrganizationDto
public bool? IsPrincipalResidenceRequired { get; set; }
public bool? IsBusinessLicenceRequired { get; set; }
public bool? IsStrProhibited { get; set; }
public bool? IsStraaExempt { get; set; }
public string? PlatformType { get; set; }
public string? BusinessLicenceFormatTxt { get; set; }
public virtual ICollection<ContactPersonDto> ContactPeople { get; set; } = new List<ContactPersonDto>();
Expand Down
1 change: 1 addition & 0 deletions server/StrDss.Model/StrRequirementsDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ public class StrRequirementsDto
public bool? IsPrincipalResidenceRequired { get; set; }
public bool? IsBusinessLicenceRequired { get; set; }
public bool? IsStrProhibited { get; set; }
public bool? IsStraaExempt { get; set; }
}
}
8 changes: 8 additions & 0 deletions server/StrDss.Service/JurisdictionValidationRules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,14 @@ public static void LoadJurisdictionValidationRules(List<FieldValidationRule> rul
Required = true
});

rules.Add(new FieldValidationRule
{
EntityName = Entities.Jurisdiction,
FieldName = JurisdictionFields.IsStraaExempt,
FieldType = FieldTypes.Bool,
Required = true
});

rules.Add(new FieldValidationRule
{
EntityName = Entities.Jurisdiction,
Expand Down
7 changes: 7 additions & 0 deletions server/StrDss.Service/RentalListingService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Task<PagedDto<RentalListingGroupDto>> GetGroupedRentalListings(string? all, stri
bool? prRequirement, bool? blRequirement, long? lgId, string[] statusArray, bool? reassigned, bool? takedownComplete, int pageSize, int pageNumber, string orderBy, string direction);
Task<int> GetGroupedRentalListingsCount(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence,
bool? prRequirement, bool? blRequirement, long? lgId, string[] statusArray, bool? reassigned, bool? takedownComplete);
Task<int> CountHostListingsAsync(string hostName);
Task<RentalListingViewDto?> GetRentalListing(long rentalListingId);
Task CreateRentalListingExportFiles();
Task<List<RentalListingExtractDto>> GetRetalListingExportsAsync();
Expand Down Expand Up @@ -91,6 +92,12 @@ public async Task<int> GetGroupedRentalListingsCount(string? all, string? addres

return count;
}

public async Task<int> CountHostListingsAsync(string hostName)
{
return await _listingRepo.CountHostListingsAsync(CommonUtils.SanitizeAndUppercaseString(hostName));
}

public async Task<RentalListingViewDto?> GetRentalListing(long rentalListingId)
{
var listing = await _listingRepo.GetRentalListing(rentalListingId);
Expand Down

0 comments on commit b0a06e4

Please sign in to comment.