@@ -43,24 +43,37 @@ public virtual async Task SetShopperDataFromMember(EvaluationContextBase evalCon
4343
4444 evalContextBase . GeoTimeZone = contact . TimeZone ;
4545
46- evalContextBase . UserGroups = contact . Groups ? . ToArray ( ) ;
46+ var userGroups = new List < string > ( ) ;
4747
48- if ( ! contact . Organizations . IsNullOrEmpty ( ) )
48+ if ( ! evalContextBase . UserGroups . IsNullOrEmpty ( ) )
4949 {
50- var userGroups = new List < string > ( ) ;
51-
52- if ( ! evalContextBase . UserGroups . IsNullOrEmpty ( ) )
53- {
54- userGroups . AddRange ( evalContextBase . UserGroups ) ;
55- }
50+ userGroups . AddRange ( evalContextBase . UserGroups ) ;
51+ }
5652
57- var organizations = await _memberService . GetByIdsAsync ( contact . Organizations . ToArray ( ) , MemberResponseGroup . WithGroups . ToString ( ) ) ;
58- userGroups . AddRange ( organizations . OfType < Organization > ( ) . SelectMany ( x => x . Groups ) ) ;
53+ userGroups . AddRange ( contact . Groups ? . ToArray ( ) ) ;
5954
60- evalContextBase . UserGroups = userGroups . Distinct ( ) . ToArray ( ) ;
61- }
55+ evalContextBase . UserGroups = userGroups . Distinct ( ) . ToArray ( ) ;
6256 }
6357 }
6458
59+ public async Task SetShopperDataFromOrganization ( EvaluationContextBase evalContextBase , string organizationId )
60+ {
61+ if ( organizationId . IsNullOrEmpty ( ) )
62+ {
63+ return ;
64+ }
65+
66+ var userGroups = new List < string > ( ) ;
67+
68+ if ( ! evalContextBase . UserGroups . IsNullOrEmpty ( ) )
69+ {
70+ userGroups . AddRange ( evalContextBase . UserGroups ) ;
71+ }
72+
73+ var organizations = await _memberService . GetByIdsAsync ( [ organizationId ] , MemberResponseGroup . WithGroups . ToString ( ) ) ;
74+ userGroups . AddRange ( organizations . OfType < Organization > ( ) . SelectMany ( x => x . Groups ) ) ;
75+
76+ evalContextBase . UserGroups = userGroups . Distinct ( ) . ToArray ( ) ;
77+ }
6578 }
6679}
0 commit comments