@@ -43,24 +43,37 @@ public virtual async Task SetShopperDataFromMember(EvaluationContextBase evalCon
43
43
44
44
evalContextBase . GeoTimeZone = contact . TimeZone ;
45
45
46
- evalContextBase . UserGroups = contact . Groups ? . ToArray ( ) ;
46
+ var userGroups = new List < string > ( ) ;
47
47
48
- if ( ! contact . Organizations . IsNullOrEmpty ( ) )
48
+ if ( ! evalContextBase . UserGroups . IsNullOrEmpty ( ) )
49
49
{
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
+ }
56
52
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 ( ) ) ;
59
54
60
- evalContextBase . UserGroups = userGroups . Distinct ( ) . ToArray ( ) ;
61
- }
55
+ evalContextBase . UserGroups = userGroups . Distinct ( ) . ToArray ( ) ;
62
56
}
63
57
}
64
58
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
+ }
65
78
}
66
79
}
0 commit comments