public Dictionary <int, HashSet <string> > Resolve(StudyDetailsDto source, IHasStudyPermissionDetails destination, Dictionary <int, HashSet <string> > destMember, ResolutionContext context) { if (source.Participants == null) { throw new ArgumentNullException("source"); } var participants = source.Participants.GroupBy(sp => sp.UserId).ToDictionary(spGrp => spGrp.Key, spGrp => new HashSet <string>(spGrp.Select(sp => sp.Role).ToList())); var hashSet = new Dictionary <int, HashSet <string> >(participants); return(hashSet); }
public async Task DecorateStudyWithPermissions(StudyDetailsDto dto) { var currentUser = await _userService.GetCurrentUserAsync(); var studyPermissionDetails = _mapper.Map <IHasStudyPermissionDetails>(dto); dto.Permissions.UpdateMetadata = _studyPermissionService.HasAccessToOperationForStudy(currentUser, studyPermissionDetails, Common.Constants.UserOperation.Study_Update_Metadata); dto.Permissions.CloseStudy = _studyPermissionService.HasAccessToOperationForStudy(currentUser, studyPermissionDetails, Common.Constants.UserOperation.Study_Close); dto.Permissions.DeleteStudy = _studyPermissionService.HasAccessToOperationForStudy(currentUser, studyPermissionDetails, Common.Constants.UserOperation.Study_Close); dto.Permissions.ReadResulsAndLearnings = _studyPermissionService.HasAccessToOperationForStudy(currentUser, studyPermissionDetails, Common.Constants.UserOperation.Study_Read_ResultsAndLearnings); dto.Permissions.UpdateResulsAndLearnings = _studyPermissionService.HasAccessToOperationForStudy(currentUser, studyPermissionDetails, Common.Constants.UserOperation.Study_Update_ResultsAndLearnings); dto.Permissions.AddRemoveDataset = _studyPermissionService.HasAccessToOperationForStudy(currentUser, studyPermissionDetails, Common.Constants.UserOperation.Study_AddRemove_Dataset); dto.Permissions.AddRemoveSandbox = _studyPermissionService.HasAccessToOperationForStudy(currentUser, studyPermissionDetails, Common.Constants.UserOperation.Study_Crud_Sandbox); dto.Permissions.AddRemoveParticipant = _studyPermissionService.HasAccessToOperationForStudy(currentUser, studyPermissionDetails, Common.Constants.UserOperation.Study_AddRemove_Participant); }