Skip to content

Commit 99a2c24

Browse files
Merge pull request #922 from bcgov/feature/DSS-1183
DSS-1183
2 parents 1ac0520 + c6d49f7 commit 99a2c24

File tree

3 files changed

+35
-29
lines changed

3 files changed

+35
-29
lines changed

server/StrDss.Api/Controllers/RentalListingsController.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ public RentalListingsController(ICurrentUser currentUser, IMapper mapper, IConfi
2929

3030
[ApiAuthorize(Permissions.ListingRead)]
3131
[HttpGet]
32-
public async Task<ActionResult> GetRentalListings(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence,
32+
public async Task<ActionResult> GetRentalListings(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence, string? registrationNumber,
3333
bool? prRequirement, bool? blRequirement, long? lgId, string? statuses, bool? reassigned, bool? takedownComplete,
3434
int pageSize = 10, int pageNumber = 1, string orderBy = "ListingStatusSortNo", string direction = "asc")
3535
{
3636
var statusArray = statuses == null ? Array.Empty<string>() : statuses!.Split(',');
3737

38-
var listings = await _listingService.GetRentalListings(all, address, url, listingId, hostName, businessLicence,
38+
var listings = await _listingService.GetRentalListings(all, address, url, listingId, hostName, businessLicence, registrationNumber,
3939
prRequirement, blRequirement, lgId, statusArray, reassigned, takedownComplete,
4040
pageSize, pageNumber, orderBy, direction);
4141

@@ -44,13 +44,13 @@ public async Task<ActionResult> GetRentalListings(string? all, string? address,
4444

4545
[ApiAuthorize(Permissions.ListingRead)]
4646
[HttpGet("grouped")]
47-
public async Task<ActionResult> GetGroupedRentalListings(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence,
47+
public async Task<ActionResult> GetGroupedRentalListings(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence, string? registrationNumber,
4848
bool? prRequirement, bool? blRequirement, long? lgId, string? statuses, bool? reassigned, bool? takedownComplete,
4949
int pageSize = 10, int pageNumber = 1, string orderBy = "matchAddressTxt", string direction = "asc")
5050
{
5151
var statusArray = statuses == null ? Array.Empty<string>() : statuses!.Split(',');
5252

53-
var listings = await _listingService.GetGroupedRentalListings(all, address, url, listingId, hostName, businessLicence,
53+
var listings = await _listingService.GetGroupedRentalListings(all, address, url, listingId, hostName, businessLicence, registrationNumber,
5454
prRequirement, blRequirement, lgId, statusArray, reassigned, takedownComplete,
5555
pageSize, pageNumber, orderBy, direction);
5656

@@ -59,12 +59,12 @@ public async Task<ActionResult> GetGroupedRentalListings(string? all, string? ad
5959

6060
[ApiAuthorize(Permissions.ListingRead)]
6161
[HttpGet("grouped/count")]
62-
public async Task<ActionResult> GetGroupedRentalListingsCount(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence,
62+
public async Task<ActionResult> GetGroupedRentalListingsCount(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence, string? registrationNumber,
6363
bool? prRequirement, bool? blRequirement, long? lgId, string? statuses, bool? reassigned, bool? takedownComplete)
6464
{
6565
var statusArray = statuses == null ? Array.Empty<string>() : statuses!.Split(',');
6666

67-
var count = await _listingService.GetGroupedRentalListingsCount(all, address, url, listingId, hostName, businessLicence,
67+
var count = await _listingService.GetGroupedRentalListingsCount(all, address, url, listingId, hostName, businessLicence, registrationNumber,
6868
prRequirement, blRequirement, lgId, statusArray, reassigned, takedownComplete);
6969

7070
return Ok(count);

server/StrDss.Data/Repositories/RentalListingRepository.cs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ namespace StrDss.Data.Repositories
1313
{
1414
public interface IRentalListingRepository
1515
{
16-
Task<PagedDto<RentalListingViewDto>> GetRentalListings(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence,
16+
Task<PagedDto<RentalListingViewDto>> GetRentalListings(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence, string? registrationNumber,
1717
bool? prRequirement, bool? blRequirement, long? lgId, string[] statusArray, bool? reassigned, bool? takedownComplete, int pageSize, int pageNumber, string orderBy, string direction);
18-
Task<PagedDto<RentalListingGroupDto>> GetGroupedRentalListings(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence,
18+
Task<PagedDto<RentalListingGroupDto>> GetGroupedRentalListings(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence, string? registrationNumber,
1919
bool? prRequirement, bool? blRequirement, long? lgId, string[] statusArray, bool? reassigned, bool? takedownComplete, int pageSize, int pageNumber, string orderBy, string direction);
20-
Task<int> GetGroupedRentalListingsCount(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence,
20+
Task<int> GetGroupedRentalListingsCount(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence, string? registrationNumber,
2121
bool? prRequirement, bool? blRequirement, long? lgId, string[] statusArray, bool? reassigned, bool? takedownComplete);
2222
Task<int> CountHostListingsAsync(string hostName);
2323
Task<RentalListingViewDto?> GetRentalListing(long rentaListingId, bool loadHistory = true);
@@ -47,7 +47,7 @@ public RentalListingRepository(DssDbContext dbContext, IMapper mapper, ICurrentU
4747
{
4848
_userRepo = userRepo;
4949
}
50-
public async Task<PagedDto<RentalListingViewDto>> GetRentalListings(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence,
50+
public async Task<PagedDto<RentalListingViewDto>> GetRentalListings(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence, string? registrationNumber,
5151
bool? prRequirement, bool? blRequirement, long? lgId, string[] statusArray, bool? reassigned, bool? takedownComplete, int pageSize, int pageNumber, string orderBy, string direction)
5252
{
5353
var query = _dbSet.AsNoTracking();
@@ -57,7 +57,7 @@ public async Task<PagedDto<RentalListingViewDto>> GetRentalListings(string? all,
5757
query = query.Where(x => x.ManagingOrganizationId == _currentUser.OrganizationId);
5858
}
5959

60-
ApplyFilters(all, address, url, listingId, hostName, businessLicence, prRequirement, blRequirement, lgId, statusArray, reassigned, takedownComplete, ref query);
60+
ApplyFilters(all, address, url, listingId, hostName, businessLicence, registrationNumber, prRequirement, blRequirement, lgId, statusArray, reassigned, takedownComplete, ref query);
6161

6262
var extraSort
6363
= "AddressSort1ProvinceCd asc, AddressSort2LocalityNm asc, AddressSort3LocalityTypeDsc asc, AddressSort4StreetNm asc, AddressSort5StreetTypeDsc asc, AddressSort6StreetDirectionDsc asc, AddressSort7CivicNo asc, AddressSort8UnitNo asc";
@@ -98,7 +98,7 @@ var extraSort
9898
return listings;
9999
}
100100

101-
public async Task<PagedDto<RentalListingGroupDto>> GetGroupedRentalListings(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence,
101+
public async Task<PagedDto<RentalListingGroupDto>> GetGroupedRentalListings(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence, string? registrationNumber,
102102
bool? prRequirement, bool? blRequirement, long? lgId, string[] statusArray, bool? reassigned, bool? takedownComplete, int pageSize, int pageNumber, string orderBy, string direction)
103103
{
104104
var stopwatch = Stopwatch.StartNew();
@@ -110,7 +110,7 @@ public async Task<PagedDto<RentalListingGroupDto>> GetGroupedRentalListings(stri
110110
query = query.Where(x => x.ManagingOrganizationId == _currentUser.OrganizationId);
111111
}
112112

113-
ApplyFilters(all, address, url, listingId, hostName, businessLicence, prRequirement, blRequirement, lgId, statusArray, reassigned, takedownComplete, ref query);
113+
ApplyFilters(all, address, url, listingId, hostName, businessLicence, registrationNumber, prRequirement, blRequirement, lgId, statusArray, reassigned, takedownComplete, ref query);
114114

115115
if (orderBy == "effectiveBusinessLicenceNo")
116116
{
@@ -136,7 +136,7 @@ public async Task<PagedDto<RentalListingGroupDto>> GetGroupedRentalListings(stri
136136
group.Listings
137137
= await GetRentalListings(
138138
group.MatchAddressTxt, group.EffectiveHostNm, group.EffectiveBusinessLicenceNo, all, address, url, listingId,
139-
hostName, businessLicence, prRequirement, blRequirement, lgId, statusArray, reassigned, takedownComplete, group);
139+
hostName, businessLicence, registrationNumber, prRequirement, blRequirement, lgId, statusArray, reassigned, takedownComplete, group);
140140
}
141141

142142
stopwatch.Stop();
@@ -146,7 +146,7 @@ public async Task<PagedDto<RentalListingGroupDto>> GetGroupedRentalListings(stri
146146
return groupedListings;
147147
}
148148

149-
public async Task<int> GetGroupedRentalListingsCount(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence,
149+
public async Task<int> GetGroupedRentalListingsCount(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence, string? registrationNumber,
150150
bool? prRequirement, bool? blRequirement, long? lgId, string[] statusArray, bool? reassigned, bool? takedownComplete)
151151
{
152152
var stopwatch = Stopwatch.StartNew();
@@ -158,7 +158,7 @@ public async Task<int> GetGroupedRentalListingsCount(string? all, string? addres
158158
query = query.Where(x => x.ManagingOrganizationId == _currentUser.OrganizationId);
159159
}
160160

161-
ApplyFilters(all, address, url, listingId, hostName, businessLicence, prRequirement, blRequirement, lgId, statusArray, reassigned, takedownComplete, ref query);
161+
ApplyFilters(all, address, url, listingId, hostName, businessLicence, registrationNumber, prRequirement, blRequirement, lgId, statusArray, reassigned, takedownComplete, ref query);
162162

163163
var count = await query
164164
.Select(x => new { x.EffectiveBusinessLicenceNo, x.EffectiveHostNm, x.MatchAddressTxt })
@@ -188,7 +188,7 @@ public async Task<int> CountHostListingsAsync(string hostName)
188188
.CountAsync();
189189
}
190190

191-
private static void ApplyFilters(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence,
191+
private static void ApplyFilters(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence, string? registrationNumber,
192192
bool? prRequirement, bool? blRequirement, long? lgId, string[] statusArray, bool? reassigned, bool? takedownComplete, ref IQueryable<DssRentalListingVw> query)
193193
{
194194
if (all != null && all.IsNotEmpty())
@@ -198,7 +198,8 @@ private static void ApplyFilters(string? all, string? address, string? url, stri
198198
(x.PlatformListingUrl != null && x.PlatformListingUrl.ToLower().Contains(allLower)) ||
199199
(x.PlatformListingNo != null && x.PlatformListingNo.ToLower().Contains(allLower)) ||
200200
(x.ListingContactNamesTxt != null && x.ListingContactNamesTxt.ToLower().Contains(allLower)) ||
201-
(x.EffectiveBusinessLicenceNo != null && x.EffectiveBusinessLicenceNo.StartsWith(CommonUtils.SanitizeAndUppercaseString(all))));
201+
(x.EffectiveBusinessLicenceNo != null && x.EffectiveBusinessLicenceNo.StartsWith(CommonUtils.SanitizeAndUppercaseString(all))) ||
202+
(x.BcRegistryNo != null && EF.Functions.ILike(x.BcRegistryNo, $"%{all}%")));
202203
}
203204

204205
if (address != null && address.IsNotEmpty())
@@ -231,6 +232,11 @@ private static void ApplyFilters(string? all, string? address, string? url, stri
231232
query = query.Where(x => x.EffectiveBusinessLicenceNo != null && x.EffectiveBusinessLicenceNo.StartsWith(effectiveBusinessLicenceNo));
232233
}
233234

235+
if (registrationNumber != null && registrationNumber.IsNotEmpty())
236+
{
237+
query = query.Where(x => x.BcRegistryNo != null && EF.Functions.ILike(x.BcRegistryNo, $"%{registrationNumber}%"));
238+
}
239+
234240
if (prRequirement != null)
235241
{
236242
query = query.Where(x => prRequirement.Value
@@ -280,15 +286,15 @@ private static void ApplyFilters(string? all, string? address, string? url, stri
280286
}
281287

282288
private async Task<List<RentalListingViewDto>> GetRentalListings(string? effectiveAddress, string? effectiveHostName, string? effectiveBusinessLicenceNo,
283-
string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence, bool? prRequirement, bool? blRequirement,
289+
string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence, string? registrationNumber, bool? prRequirement, bool? blRequirement,
284290
long? lgId, string[] statusArray, bool? reassigned, bool? takedownComplete, RentalListingGroupDto group)
285291
{
286292
var stopwatch = Stopwatch.StartNew();
287293

288294
var query = _dbSet.AsNoTracking()
289295
.Where(x => x.MatchAddressTxt == effectiveAddress && x.EffectiveHostNm == effectiveHostName && x.EffectiveBusinessLicenceNo == effectiveBusinessLicenceNo);
290296

291-
ApplyFilters(all, address, url, listingId, hostName, businessLicence, prRequirement, blRequirement, lgId, statusArray, reassigned, takedownComplete, ref query);
297+
ApplyFilters(all, address, url, listingId, hostName, businessLicence, registrationNumber, prRequirement, blRequirement, lgId, statusArray, reassigned, takedownComplete, ref query);
292298

293299
var filteredIds = await query.Select(x => x.RentalListingId ?? 0).ToListAsync();
294300

server/StrDss.Service/RentalListingService.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ namespace StrDss.Service
1515
{
1616
public interface IRentalListingService
1717
{
18-
Task<PagedDto<RentalListingViewDto>> GetRentalListings(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence,
18+
Task<PagedDto<RentalListingViewDto>> GetRentalListings(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence, string? registrationNumber,
1919
bool? prRequirement, bool? blRequirement, long? lgId, string[] statusArray, bool? reassigned, bool? takedownComplete, int pageSize, int pageNumber, string orderBy, string direction);
20-
Task<PagedDto<RentalListingGroupDto>> GetGroupedRentalListings(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence,
20+
Task<PagedDto<RentalListingGroupDto>> GetGroupedRentalListings(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence, string? registrationNumber,
2121
bool? prRequirement, bool? blRequirement, long? lgId, string[] statusArray, bool? reassigned, bool? takedownComplete, int pageSize, int pageNumber, string orderBy, string direction);
22-
Task<int> GetGroupedRentalListingsCount(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence,
22+
Task<int> GetGroupedRentalListingsCount(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence, string? registrationNumber,
2323
bool? prRequirement, bool? blRequirement, long? lgId, string[] statusArray, bool? reassigned, bool? takedownComplete);
2424
Task<int> CountHostListingsAsync(string hostName);
2525
Task<RentalListingViewDto?> GetRentalListing(long rentalListingId);
@@ -51,10 +51,10 @@ public RentalListingService(ICurrentUser currentUser, IFieldValidatorService val
5151
_orgRepo = orgRepo;
5252
_bizLicenceRepo = bizLicenceRepo;
5353
}
54-
public async Task<PagedDto<RentalListingViewDto>> GetRentalListings(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence,
54+
public async Task<PagedDto<RentalListingViewDto>> GetRentalListings(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence, string? registrationNumber,
5555
bool? prRequirement, bool? blRequirement, long? lgId, string[] statusArray, bool? reassigned, bool? takedownComplete, int pageSize, int pageNumber, string orderBy, string direction)
5656
{
57-
var listings = await _listingRepo.GetRentalListings(all, address, url, listingId, hostName, businessLicence,
57+
var listings = await _listingRepo.GetRentalListings(all, address, url, listingId, hostName, businessLicence, registrationNumber,
5858
prRequirement, blRequirement, lgId, statusArray, reassigned, takedownComplete,
5959
pageSize, pageNumber, orderBy, direction);
6060

@@ -66,10 +66,10 @@ public async Task<PagedDto<RentalListingViewDto>> GetRentalListings(string? all,
6666
return listings;
6767
}
6868

69-
public async Task<PagedDto<RentalListingGroupDto>> GetGroupedRentalListings(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence,
69+
public async Task<PagedDto<RentalListingGroupDto>> GetGroupedRentalListings(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence, string? registrationNumber,
7070
bool? prRequirement, bool? blRequirement, long? lgId, string[] statusArray, bool? reassigned, bool? takedownComplete, int pageSize, int pageNumber, string orderBy, string direction)
7171
{
72-
var listings = await _listingRepo.GetGroupedRentalListings(all, address, url, listingId, hostName, businessLicence,
72+
var listings = await _listingRepo.GetGroupedRentalListings(all, address, url, listingId, hostName, businessLicence, registrationNumber,
7373
prRequirement, blRequirement, lgId, statusArray, reassigned, takedownComplete,
7474
pageSize, pageNumber, orderBy, direction);
7575

@@ -84,10 +84,10 @@ public async Task<PagedDto<RentalListingGroupDto>> GetGroupedRentalListings(stri
8484
return listings;
8585
}
8686

87-
public async Task<int> GetGroupedRentalListingsCount(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence,
87+
public async Task<int> GetGroupedRentalListingsCount(string? all, string? address, string? url, string? listingId, string? hostName, string? businessLicence, string? registrationNumber,
8888
bool? prRequirement, bool? blRequirement, long? lgId, string[] statusArray, bool? reassigned, bool? takedownComplete)
8989
{
90-
var count = await _listingRepo.GetGroupedRentalListingsCount(all, address, url, listingId, hostName, businessLicence,
90+
var count = await _listingRepo.GetGroupedRentalListingsCount(all, address, url, listingId, hostName, businessLicence, registrationNumber,
9191
prRequirement, blRequirement, lgId, statusArray, reassigned, takedownComplete);
9292

9393
return count;

0 commit comments

Comments
 (0)