@@ -71,9 +71,34 @@ public override Task<Resource> DeleteAsync(IResourceIdentifier resourceIdentifie
71
71
this . storage . Users . Remove ( identifier ) ;
72
72
return Task . FromResult ( ( Resource ) user ) ;
73
73
}
74
+
74
75
throw new CustomHttpResponseException ( HttpStatusCode . NotFound ) ;
75
76
}
76
77
78
+ public override async Task < QueryResponseBase > PaginateQueryAsync ( IRequest < IQueryParameters > request )
79
+ {
80
+ if ( null == request )
81
+ {
82
+ throw new ArgumentNullException ( nameof ( request ) ) ;
83
+ }
84
+
85
+ IReadOnlyCollection < Resource > resources = await this . QueryAsync ( request ) . ConfigureAwait ( false ) ;
86
+ int totalCount = resources . Count ;
87
+ if ( request . Payload . PaginationParameters != null )
88
+ {
89
+ int count = request . Payload . PaginationParameters ? . Count ?? 0 ;
90
+ resources = ( IReadOnlyCollection < Resource > ) resources . Take ( count ) ;
91
+ }
92
+
93
+
94
+ QueryResponseBase result = new QueryResponse ( resources ) ;
95
+ result . TotalResults = totalCount ;
96
+ result . ItemsPerPage = resources . Count ;
97
+
98
+ result . StartIndex = resources . Any ( ) ? 1 : null ;
99
+ return result ;
100
+ }
101
+
77
102
public override Task < Resource [ ] > QueryAsync ( IQueryParameters parameters , string correlationIdentifier )
78
103
{
79
104
if ( parameters == null )
@@ -110,7 +135,6 @@ public override Task<Resource[]> QueryAsync(IQueryParameters parameters, string
110
135
}
111
136
else
112
137
{
113
-
114
138
foreach ( IFilter queryFilter in parameters . AlternateFilters )
115
139
{
116
140
predicateAnd = PredicateBuilder . True < Core2EnterpriseUser > ( ) ;
@@ -121,16 +145,19 @@ public override Task<Resource[]> QueryAsync(IQueryParameters parameters, string
121
145
{
122
146
if ( string . IsNullOrWhiteSpace ( andFilter . AttributePath ) )
123
147
{
124
- throw new ArgumentException ( SystemForCrossDomainIdentityManagementServiceResources . ExceptionInvalidParameters ) ;
148
+ throw new ArgumentException ( SystemForCrossDomainIdentityManagementServiceResources
149
+ . ExceptionInvalidParameters ) ;
125
150
}
126
151
127
152
else if ( string . IsNullOrWhiteSpace ( andFilter . ComparisonValue ) )
128
153
{
129
- throw new ArgumentException ( SystemForCrossDomainIdentityManagementServiceResources . ExceptionInvalidParameters ) ;
154
+ throw new ArgumentException ( SystemForCrossDomainIdentityManagementServiceResources
155
+ . ExceptionInvalidParameters ) ;
130
156
}
131
157
132
158
// ID filter
133
- else if ( andFilter . AttributePath . Equals ( AttributeNames . Identifier , StringComparison . OrdinalIgnoreCase ) )
159
+ else if ( andFilter . AttributePath . Equals ( AttributeNames . Identifier ,
160
+ StringComparison . OrdinalIgnoreCase ) )
134
161
{
135
162
if ( andFilter . FilterOperator != ComparisonOperator . Equals )
136
163
{
@@ -141,18 +168,21 @@ public override Task<Resource[]> QueryAsync(IQueryParameters parameters, string
141
168
}
142
169
143
170
var id = andFilter . ComparisonValue ;
144
- predicateAnd = predicateAnd . And ( p => string . Equals ( p . Identifier , id , StringComparison . OrdinalIgnoreCase ) ) ;
171
+ predicateAnd = predicateAnd . And ( p =>
172
+ string . Equals ( p . Identifier , id , StringComparison . OrdinalIgnoreCase ) ) ;
145
173
}
146
174
147
175
// UserName filter
148
- else if ( andFilter . AttributePath . Equals ( AttributeNames . UserName , StringComparison . OrdinalIgnoreCase ) )
176
+ else if ( andFilter . AttributePath . Equals ( AttributeNames . UserName ,
177
+ StringComparison . OrdinalIgnoreCase ) )
149
178
{
150
179
if ( andFilter . FilterOperator != ComparisonOperator . Equals )
151
180
{
152
181
throw new ScimTypeException ( ErrorType . invalidFilter ,
153
182
string . Format (
154
183
SystemForCrossDomainIdentityManagementServiceResources
155
- . ExceptionFilterOperatorNotSupportedTemplate , andFilter . FilterOperator ) ) ;
184
+ . ExceptionFilterOperatorNotSupportedTemplate ,
185
+ andFilter . FilterOperator ) ) ;
156
186
}
157
187
158
188
string userName = andFilter . ComparisonValue ;
@@ -173,13 +203,13 @@ public override Task<Resource[]> QueryAsync(IQueryParameters parameters, string
173
203
}
174
204
175
205
string externalIdentifier = andFilter . ComparisonValue ;
176
- predicateAnd = predicateAnd . And ( p => string . Equals ( p . ExternalIdentifier , externalIdentifier , StringComparison . OrdinalIgnoreCase ) ) ;
177
-
178
-
206
+ predicateAnd = predicateAnd . And ( p => string . Equals ( p . ExternalIdentifier , externalIdentifier ,
207
+ StringComparison . OrdinalIgnoreCase ) ) ;
179
208
}
180
209
181
210
//Active Filter
182
- else if ( andFilter . AttributePath . Equals ( AttributeNames . Active , StringComparison . OrdinalIgnoreCase ) )
211
+ else if ( andFilter . AttributePath . Equals ( AttributeNames . Active ,
212
+ StringComparison . OrdinalIgnoreCase ) )
183
213
{
184
214
if ( andFilter . FilterOperator != ComparisonOperator . Equals )
185
215
{
@@ -194,7 +224,8 @@ public override Task<Resource[]> QueryAsync(IQueryParameters parameters, string
194
224
}
195
225
196
226
// DisplayName Filter
197
- else if ( andFilter . AttributePath . Equals ( AttributeNames . DisplayName , StringComparison . OrdinalIgnoreCase ) )
227
+ else if ( andFilter . AttributePath . Equals ( AttributeNames . DisplayName ,
228
+ StringComparison . OrdinalIgnoreCase ) )
198
229
{
199
230
if ( andFilter . FilterOperator != ComparisonOperator . Equals )
200
231
{
@@ -245,15 +276,7 @@ public override Task<Resource[]> QueryAsync(IQueryParameters parameters, string
245
276
results = this . storage . Users . Values . Where ( predicate . Compile ( ) ) ;
246
277
}
247
278
248
- if ( parameters . PaginationParameters != null )
249
- {
250
- int count = parameters . PaginationParameters . Count . HasValue
251
- ? parameters . PaginationParameters . Count . Value
252
- : 0 ;
253
- return Task . FromResult ( results . Take ( count ) . ToArray ( ) ) ;
254
- }
255
- else
256
- return Task . FromResult ( results . ToArray ( ) ) ;
279
+ return Task . FromResult ( results . ToArray ( ) ) ;
257
280
}
258
281
259
282
public override Task < Resource > ReplaceAsync ( Resource resource , string correlationIdentifier )
@@ -278,7 +301,9 @@ public override Task<Resource> ReplaceAsync(Resource resource, string correlatio
278
301
! string . Equals ( exisitingUser . Identifier , user . Identifier , StringComparison . OrdinalIgnoreCase ) )
279
302
)
280
303
{
281
- throw new CustomHttpResponseException ( HttpStatusCode . Conflict ) ;
304
+ throw new ScimTypeException ( ErrorType . uniqueness , string . Format (
305
+ SystemForCrossDomainIdentityManagementServiceResources
306
+ . ExceptionResourceConflict ) ) ;
282
307
}
283
308
284
309
Core2EnterpriseUser exisitingUser = this . storage . Users . Values
@@ -339,17 +364,20 @@ public override Task<Resource> UpdateAsync(IPatch patch, string correlationIdent
339
364
340
365
if ( null == patch . ResourceIdentifier )
341
366
{
342
- throw new ArgumentException ( string . Format ( SystemForCrossDomainIdentityManagementServiceResources . ExceptionInvalidOperation ) ) ;
367
+ throw new ArgumentException ( string . Format ( SystemForCrossDomainIdentityManagementServiceResources
368
+ . ExceptionInvalidOperation ) ) ;
343
369
}
344
370
345
371
if ( string . IsNullOrWhiteSpace ( patch . ResourceIdentifier . Identifier ) )
346
372
{
347
- throw new ArgumentException ( SystemForCrossDomainIdentityManagementServiceResources . ExceptionInvalidOperation ) ;
373
+ throw new ArgumentException ( SystemForCrossDomainIdentityManagementServiceResources
374
+ . ExceptionInvalidOperation ) ;
348
375
}
349
376
350
377
if ( null == patch . PatchRequest )
351
378
{
352
- throw new ArgumentException ( SystemForCrossDomainIdentityManagementServiceResources . ExceptionInvalidOperation ) ;
379
+ throw new ArgumentException ( SystemForCrossDomainIdentityManagementServiceResources
380
+ . ExceptionInvalidOperation ) ;
353
381
}
354
382
355
383
PatchRequest2 patchRequest =
0 commit comments