@@ -13,11 +13,11 @@ namespace StrDss.Data.Repositories
13
13
{
14
14
public interface IRentalListingRepository
15
15
{
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 ,
17
17
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 ,
19
19
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 ,
21
21
bool ? prRequirement , bool ? blRequirement , long ? lgId , string [ ] statusArray , bool ? reassigned , bool ? takedownComplete ) ;
22
22
Task < int > CountHostListingsAsync ( string hostName ) ;
23
23
Task < RentalListingViewDto ? > GetRentalListing ( long rentaListingId , bool loadHistory = true ) ;
@@ -47,7 +47,7 @@ public RentalListingRepository(DssDbContext dbContext, IMapper mapper, ICurrentU
47
47
{
48
48
_userRepo = userRepo ;
49
49
}
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 ,
51
51
bool ? prRequirement , bool ? blRequirement , long ? lgId , string [ ] statusArray , bool ? reassigned , bool ? takedownComplete , int pageSize , int pageNumber , string orderBy , string direction )
52
52
{
53
53
var query = _dbSet . AsNoTracking ( ) ;
@@ -57,7 +57,7 @@ public async Task<PagedDto<RentalListingViewDto>> GetRentalListings(string? all,
57
57
query = query . Where ( x => x . ManagingOrganizationId == _currentUser . OrganizationId ) ;
58
58
}
59
59
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 ) ;
61
61
62
62
var extraSort
63
63
= "AddressSort1ProvinceCd asc, AddressSort2LocalityNm asc, AddressSort3LocalityTypeDsc asc, AddressSort4StreetNm asc, AddressSort5StreetTypeDsc asc, AddressSort6StreetDirectionDsc asc, AddressSort7CivicNo asc, AddressSort8UnitNo asc" ;
@@ -98,7 +98,7 @@ var extraSort
98
98
return listings ;
99
99
}
100
100
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 ,
102
102
bool ? prRequirement , bool ? blRequirement , long ? lgId , string [ ] statusArray , bool ? reassigned , bool ? takedownComplete , int pageSize , int pageNumber , string orderBy , string direction )
103
103
{
104
104
var stopwatch = Stopwatch . StartNew ( ) ;
@@ -110,7 +110,7 @@ public async Task<PagedDto<RentalListingGroupDto>> GetGroupedRentalListings(stri
110
110
query = query . Where ( x => x . ManagingOrganizationId == _currentUser . OrganizationId ) ;
111
111
}
112
112
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 ) ;
114
114
115
115
if ( orderBy == "effectiveBusinessLicenceNo" )
116
116
{
@@ -136,7 +136,7 @@ public async Task<PagedDto<RentalListingGroupDto>> GetGroupedRentalListings(stri
136
136
group . Listings
137
137
= await GetRentalListings (
138
138
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 ) ;
140
140
}
141
141
142
142
stopwatch . Stop ( ) ;
@@ -146,7 +146,7 @@ public async Task<PagedDto<RentalListingGroupDto>> GetGroupedRentalListings(stri
146
146
return groupedListings ;
147
147
}
148
148
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 ,
150
150
bool ? prRequirement , bool ? blRequirement , long ? lgId , string [ ] statusArray , bool ? reassigned , bool ? takedownComplete )
151
151
{
152
152
var stopwatch = Stopwatch . StartNew ( ) ;
@@ -158,7 +158,7 @@ public async Task<int> GetGroupedRentalListingsCount(string? all, string? addres
158
158
query = query . Where ( x => x . ManagingOrganizationId == _currentUser . OrganizationId ) ;
159
159
}
160
160
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 ) ;
162
162
163
163
var count = await query
164
164
. Select ( x => new { x . EffectiveBusinessLicenceNo , x . EffectiveHostNm , x . MatchAddressTxt } )
@@ -188,7 +188,7 @@ public async Task<int> CountHostListingsAsync(string hostName)
188
188
. CountAsync ( ) ;
189
189
}
190
190
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 ,
192
192
bool ? prRequirement , bool ? blRequirement , long ? lgId , string [ ] statusArray , bool ? reassigned , bool ? takedownComplete , ref IQueryable < DssRentalListingVw > query )
193
193
{
194
194
if ( all != null && all . IsNotEmpty ( ) )
@@ -198,7 +198,8 @@ private static void ApplyFilters(string? all, string? address, string? url, stri
198
198
( x . PlatformListingUrl != null && x . PlatformListingUrl . ToLower ( ) . Contains ( allLower ) ) ||
199
199
( x . PlatformListingNo != null && x . PlatformListingNo . ToLower ( ) . Contains ( allLower ) ) ||
200
200
( 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 } %") ) ) ;
202
203
}
203
204
204
205
if ( address != null && address . IsNotEmpty ( ) )
@@ -231,6 +232,11 @@ private static void ApplyFilters(string? all, string? address, string? url, stri
231
232
query = query . Where ( x => x . EffectiveBusinessLicenceNo != null && x . EffectiveBusinessLicenceNo . StartsWith ( effectiveBusinessLicenceNo ) ) ;
232
233
}
233
234
235
+ if ( registrationNumber != null && registrationNumber . IsNotEmpty ( ) )
236
+ {
237
+ query = query . Where ( x => x . BcRegistryNo != null && EF . Functions . ILike ( x . BcRegistryNo , $ "%{ registrationNumber } %") ) ;
238
+ }
239
+
234
240
if ( prRequirement != null )
235
241
{
236
242
query = query . Where ( x => prRequirement . Value
@@ -280,15 +286,15 @@ private static void ApplyFilters(string? all, string? address, string? url, stri
280
286
}
281
287
282
288
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 ,
284
290
long ? lgId , string [ ] statusArray , bool ? reassigned , bool ? takedownComplete , RentalListingGroupDto group )
285
291
{
286
292
var stopwatch = Stopwatch . StartNew ( ) ;
287
293
288
294
var query = _dbSet . AsNoTracking ( )
289
295
. Where ( x => x . MatchAddressTxt == effectiveAddress && x . EffectiveHostNm == effectiveHostName && x . EffectiveBusinessLicenceNo == effectiveBusinessLicenceNo ) ;
290
296
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 ) ;
292
298
293
299
var filteredIds = await query . Select ( x => x . RentalListingId ?? 0 ) . ToListAsync ( ) ;
294
300
0 commit comments