/// <summary> /// Gets a list of groups with group attributes for either the logged in user or a participant you pass in. /// </summary> /// <param name="token"></param> /// <param name="participantId">if null we load the calling user's participant record</param> /// <param name="groupTypeId"></param> /// <param name="groupId"></param> /// <returns></returns> public List <GroupDTO> GetGroupsByTypeOrId(string token, int?participantId = null, int[] groupTypeIds = null, int?groupId = null, bool?withParticipants = true, bool?withAttributes = true) { if (participantId == null) { participantId = _participantService.GetParticipantRecord(token).ParticipantId; } var groupsByType = _mpGroupRepository.GetGroupsForParticipantByTypeOrID(participantId.Value, null, groupTypeIds, groupId); if (groupsByType == null) { return(null); } var groupDetail = groupsByType.Select(Mapper.Map <MpGroup, GroupDTO>).ToList(); if (withAttributes == true) { var configuration = MpObjectAttributeConfigurationFactory.Group(); var mpAttributes = _attributeRepository.GetAttributes(null); foreach (var group in groupDetail) { var attributesTypes = _objectAttributeService.GetObjectAttributes(token, group.GroupId, configuration, mpAttributes); group.AttributeTypes = attributesTypes.MultiSelect; group.SingleAttributes = attributesTypes.SingleSelect; } } if (withParticipants == true) { GetGroupParticipants(groupDetail); } return(groupDetail); }