private void Apply(UserPermissionGrantedEvent @event) { foreach (var permission in @event.PermissionsToGrant) { PermissionList[permission.Key] = permission.Value; } }
private async Task <string> Descriptify <T>(UserPermissionGrantedEvent e) where T : UserPermissionGrantedEvent { //get list of permission in the list of Granted Permissions var permissions = await _context.PermissionDetailProjection.Where(a => e.PermissionsToGrant.ContainsKey(a.PermissionId)) .ToListAsync(); var dict = new Dictionary <string, string>(); // put them into a dict where key= PermissionName, Value= Reason for Granting. foreach (var permissionDetailProjection in permissions) { dict.Add(permissionDetailProjection.Name, e.PermissionsToGrant[permissionDetailProjection.PermissionId].Reason); } return(JsonConvert.SerializeObject(dict)); }