@@ -76,7 +76,9 @@ public override IAsyncEnumerable<StoreReadOnly> GetEntitiesAsync(CancellationTok
76
76
GiftCardDaysValid = entity . GiftCardDaysValid ,
77
77
GiftCardCodeTemplate = entity . GiftCardCodeTemplate ,
78
78
GiftCardPropertyAliases = entity . GiftCardPropertyAliases ,
79
- GiftCardActivationMethod = ( int ) entity . GiftCardActivationMethod
79
+ GiftCardActivationMethod = ( int ) entity . GiftCardActivationMethod ,
80
+ AllowedUsers = entity . AllowedUsers . Select ( x => x . UserId ) . ToList ( ) ,
81
+ AllowedUserRoles = entity . AllowedUserRoles . Select ( x => x . Role ) . ToList ( ) ,
80
82
} ;
81
83
82
84
// Base currency
@@ -169,52 +171,6 @@ public override IAsyncEnumerable<StoreReadOnly> GetEntitiesAsync(CancellationTok
169
171
artifact . ErrorEmailTemplateUdi = depUdi ;
170
172
}
171
173
172
- // Allowed users
173
- // NB: Users can't be deployed so don't add to dependencies collection
174
- // instead we'll just have to hope that they exist on all environments
175
- // and if not, when it comes to restore, we'll just not set anything
176
- if ( entity . AllowedUsers . Count > 0 )
177
- {
178
- var users = new List < string > ( ) ;
179
-
180
- foreach ( var id in entity . AllowedUsers )
181
- {
182
- var user = _userService . GetByProviderKey ( id . UserId ) ;
183
- if ( user != null )
184
- {
185
- users . Add ( user . Username ) ;
186
- }
187
- }
188
-
189
- if ( users . Count > 0 )
190
- {
191
- artifact . AllowedUsers = users ;
192
- }
193
- }
194
-
195
- // Allowed user roles
196
- // NB: Users roles can't be deployed so don't add to dependencies collection
197
- // instead we'll just have to hope that they exist on all environments
198
- // and if not, when it comes to restore, we'll just not set anything
199
- if ( entity . AllowedUserRoles . Count > 0 )
200
- {
201
- var userRoles = new List < string > ( ) ;
202
-
203
- foreach ( var role in entity . AllowedUserRoles )
204
- {
205
- var userGroup = _userService . GetUserGroupByAlias ( role . Role ) ;
206
- if ( userGroup != null )
207
- {
208
- userRoles . Add ( userGroup . Alias ) ;
209
- }
210
- }
211
-
212
- if ( userRoles . Count > 0 )
213
- {
214
- artifact . AllowedUserRoles = userRoles ;
215
- }
216
- }
217
-
218
174
// Stock sharing store
219
175
if ( entity . ShareStockFromStoreId . HasValue )
220
176
{
@@ -244,9 +200,9 @@ public override async Task ProcessAsync(ArtifactDeployState<StoreArtifact, Store
244
200
}
245
201
}
246
202
247
- private Task Pass1Async ( ArtifactDeployState < StoreArtifact , StoreReadOnly > state , IDeployContext context , CancellationToken cancellationToken = default )
248
- => _umbracoCommerceApi . Uow . ExecuteAsync (
249
- ( uow , ct ) =>
203
+ private async Task Pass1Async ( ArtifactDeployState < StoreArtifact , StoreReadOnly > state , IDeployContext context , CancellationToken cancellationToken = default )
204
+ => await _umbracoCommerceApi . Uow . ExecuteAsync (
205
+ async ( uow , ct ) =>
250
206
{
251
207
StoreArtifact artifact = state . Artifact ;
252
208
@@ -272,7 +228,9 @@ private Task Pass1Async(ArtifactDeployState<StoreArtifact, StoreReadOnly> state,
272
228
. SetGiftCardValidityTimeframe ( artifact . GiftCardDaysValid )
273
229
. SetGiftCardPropertyAliases ( artifact . GiftCardPropertyAliases , SetBehavior . Replace )
274
230
. SetGiftCardActivationMethod ( ( GiftCardActivationMethod ) artifact . GiftCardActivationMethod )
275
- . SetSortOrder ( artifact . SortOrder ) ;
231
+ . SetSortOrder ( artifact . SortOrder )
232
+ . SetAllowedUsers ( artifact . AllowedUsers )
233
+ . SetAllowedUserRoles ( artifact . AllowedUserRoles ) ;
276
234
277
235
if ( artifact . CookieTimeout . HasValue )
278
236
{
@@ -283,35 +241,14 @@ private Task Pass1Async(ArtifactDeployState<StoreArtifact, StoreReadOnly> state,
283
241
entity . DisableCookies ( ) ;
284
242
}
285
243
286
- if ( artifact . AllowedUsers != null && artifact . AllowedUsers . Any ( ) )
287
- {
288
- var userIds = artifact . AllowedUsers . Select ( x => _userService . GetByUsername ( x ) )
289
- . Where ( x => x != null )
290
- . Select ( x => x . Id . ToString ( CultureInfo . InvariantCulture ) )
291
- . ToList ( ) ;
292
-
293
- entity . SetAllowedUsers ( userIds , SetBehavior . Replace ) ;
294
- }
295
-
296
- if ( artifact . AllowedUserRoles != null && artifact . AllowedUserRoles . Any ( ) )
297
- {
298
- var userRoles = artifact . AllowedUserRoles . Select ( x => _userService . GetUserGroupByAlias ( x ) )
299
- . Where ( x => x != null )
300
- . Select ( x => x . Alias )
301
- . ToList ( ) ;
302
-
303
- entity . SetAllowedUserRoles ( userRoles , SetBehavior . Replace ) ;
304
- }
305
-
306
244
_umbracoCommerceApi . SaveStore ( entity ) ;
307
245
308
246
state . Entity = entity ;
309
247
310
248
uow . Complete ( ) ;
311
-
312
- return Task . CompletedTask ;
313
249
} ,
314
- cancellationToken ) ;
250
+ cancellationToken )
251
+ . ConfigureAwait ( false ) ;
315
252
316
253
private Task Pass4Async ( ArtifactDeployState < StoreArtifact , StoreReadOnly > state , IDeployContext context , CancellationToken cancellationToken = default ) =>
317
254
_umbracoCommerceApi . Uow . ExecuteAsync (
0 commit comments