public static string GetGroupName(int id)
 {
     API.Group group = PublicApi.Groups.Get(new GroupsGetOptions
     {
         Id = id
     });
     return(group.Name);
 }
 public static API.Group GetGroupById(int?id)
 {
     API.Group group = PublicApi.Groups.Get(new GroupsGetOptions
     {
         Id = id
     });
     return(group);
 }
Esempio n. 3
0
        internal static PagedList <Poll> ListPolls(Telligent.Evolution.Extensibility.Api.Entities.Version1.Group group, User user, Guid[] filterGroupIds, PollsApi.PollsListOptions options)
        {
            List <Poll> polls = new List <Poll>();

            using (var connection = GetSqlConnection())
            {
                using (var command = CreateSprocCommand("[polling_Polls_List]", connection))
                {
                    PollsQueryBuilder queryBuilder = new PollsQueryBuilder(group, user, filterGroupIds, options);

                    command.Parameters.Add("@sql", SqlDbType.NVarChar, -1).Value     = queryBuilder.BuildQuery();
                    command.Parameters.Add("@TotalRecords", SqlDbType.Int).Direction = ParameterDirection.Output;

                    for (int i = 0; i < queryBuilder.SqlParameters.Length; i++)
                    {
                        command.Parameters.Add(queryBuilder.SqlParameters[i]);
                    }

                    connection.Open();
                    using (var reader = command.ExecuteReader())
                    {
                        Dictionary <Guid, Poll> pollsById = new Dictionary <Guid, Poll>();

                        while (reader.Read())
                        {
                            var poll = PopulatePoll(reader);
                            pollsById[poll.Id] = poll;
                            polls.Add(poll);
                        }

                        reader.NextResult();

                        while (reader.Read())
                        {
                            var  pollAnswer = PopulatePollAnswer(reader);
                            Poll poll;
                            if (pollsById.TryGetValue(pollAnswer.PollId, out poll))
                            {
                                poll.Answers.Add(pollAnswer);
                            }
                        }

                        reader.Close();
                    }
                    connection.Close();

                    return(new PagedList <Poll>(polls, options.PageSize, options.PageIndex, (int)command.Parameters["@TotalRecords"].Value));
                }
            }
        }
 public static IList <API.Group> GetChildGroups(API.Group group)
 {
     return(GetChildGroups(group.Id));
 }