コード例 #1
0
        public Contracts.GenericListResult <Contracts.GenericReference> GetPersonSmallGroupLeadership(int id, int start, int max)
        {
            Contracts.GenericListResult <Contracts.GenericReference> list = new Contracts.GenericListResult <Contracts.GenericReference>();
            GroupCollection gc = new GroupCollection();


            //
            // If they are requesting membership for a person, get the list
            // of groups this person is a member of. Does not return groups
            // this person is a leader of.
            //
            list.Items = new List <Contracts.GenericReference>();
            gc.LoadByLeaderPersonID(id);
            list.Start = start;
            list.Max   = max;
            foreach (Group g in gc)
            {
                if (RestApi.GroupClusterOperationAllowed(ArenaContext.Current.Person.PersonID, g.GroupClusterID, OperationType.View) == false)
                {
                    continue;
                }

                if (list.Total >= start && list.Items.Count < max)
                {
                    list.Items.Add(new Contracts.GenericReference(g));
                }
            }

            return(list);
        }
コード例 #2
0
        public Contracts.GenericListResult <Contracts.SmallGroupMember> GetSmallGroupMembers(int groupID, int start, int max)
        {
            Contracts.GenericListResult <Contracts.SmallGroupMember> list = new Contracts.GenericListResult <Contracts.SmallGroupMember>();
            Contracts.SmallGroupMemberMapper mapper = new Contracts.SmallGroupMemberMapper();
            Group group = new Group(groupID);
            int   i;


            if (RestApi.GroupClusterOperationAllowed(ArenaContext.Current.Person.PersonID, group.GroupClusterID, OperationType.View) == false)
            {
                throw new Exception("Access denied.");
            }

            group.LoadMemberArray();
            list.Start = start;
            list.Max   = max;
            list.Total = group.Members.Count;
            list.Items = new List <Contracts.SmallGroupMember>();

            for (i = start; i < group.Members.Count && (max <= 0 || i < (start + max)); i++)
            {
                list.Items.Add(mapper.FromArena(group.Members[i]));
            }

            return(list);
        }
コード例 #3
0
        public Contracts.GenericListResult <Contracts.SmallGroupMember> GetPersonSmallGroupMembership(int id, int start, int max)
        {
            Contracts.GenericListResult <Contracts.SmallGroupMember> list = new Contracts.GenericListResult <Contracts.SmallGroupMember>();
            Contracts.SmallGroupMemberMapper mapper = new Contracts.SmallGroupMemberMapper();
            Contracts.SmallGroupMember       member;
            CategoryCollection cc = new CategoryCollection();
            GroupCollection    gc = new GroupCollection();
            GroupMember        gm;


            //
            // If they are requesting membership for a person, get the list
            // of groups this person is a member of. Does not return groups
            // this person is a leader of.
            //
            list.Items = new List <Contracts.SmallGroupMember>();
            list.Start = start;
            list.Max   = max;
            foreach (Category c in cc)
            {
                gc = new GroupCollection();
                gc.LoadByPersonID(id, c.CategoryID);

                foreach (Group g in gc)
                {
                    if (RestApi.GroupClusterOperationAllowed(ArenaContext.Current.Person.PersonID, g.GroupClusterID, OperationType.View) == false)
                    {
                        continue;
                    }

                    if (list.Total >= start && list.Items.Count < max)
                    {
                        gm     = new GroupMember(g.GroupID, id);
                        member = mapper.FromArena(new GroupMember(g.GroupID, id));
                        if (member.Group.ID == -1)
                        {
                            continue;
                        }

                        list.Items.Add(mapper.FromArena(gm));
                    }

                    list.Total += 1;
                }
            }

            return(list);
        }
コード例 #4
0
        public Contracts.SmallGroup GetSmallGroup(int groupID)
        {
            Contracts.SmallGroupMapper mapper = new Contracts.SmallGroupMapper();
            Group group = new Group(groupID);


            if (group.GroupID == -1)
            {
                throw new Arena.Services.Exceptions.ResourceNotFoundException("Invalid group ID");
            }

            if (RestApi.GroupClusterOperationAllowed(ArenaContext.Current.Person.PersonID, group.GroupClusterID, OperationType.View) == false)
            {
                throw new Exception("Access denied.");
            }

            return(mapper.FromArena(group));
        }
コード例 #5
0
        public Contracts.GenericListResult <Contracts.GenericReference> GetSmallGroupClusters(String categoryID, String clusterID, int start, int max)
        {
            GroupClusterCollection clusters;

            Contracts.GenericListResult <Contracts.GenericReference> list = new Contracts.GenericListResult <Contracts.GenericReference>();
            int i;


            if (categoryID != null)
            {
                clusters = new GroupClusterCollection(Convert.ToInt32(categoryID), Convert.ToInt32(ConfigurationManager.AppSettings["Organization"]));
            }
            else if (clusterID != null)
            {
                if (RestApi.GroupClusterOperationAllowed(ArenaContext.Current.Person.PersonID, Convert.ToInt32(clusterID), OperationType.View) == false)
                {
                    throw new Exception("Access denied.");
                }

                clusters = new GroupClusterCollection(Convert.ToInt32(clusterID));
            }
            else
            {
                throw new Exception("Required parameters not provided.");
            }

            list.Start = start;
            list.Max   = max;
            list.Total = clusters.Count;
            list.Items = new List <Contracts.GenericReference>();
            clusters.Sort(delegate(GroupCluster gc1, GroupCluster gc2) { return(gc1.Name.CompareTo(gc2.Name)); });
            for (i = start; i < clusters.Count && (max <= 0 || i < (start + max)); i++)
            {
                if (RestApi.GroupClusterOperationAllowed(ArenaContext.Current.Person.PersonID, clusters[i].GroupClusterID, OperationType.View) == true)
                {
                    list.Items.Add(new Contracts.GenericReference(clusters[i]));
                }
            }

            return(list);
        }
コード例 #6
0
        public Contracts.GenericListResult <Contracts.GenericReference> GetSmallGroups(int clusterID, int start, int max)
        {
            Contracts.GenericListResult <Contracts.GenericReference> list = new Contracts.GenericListResult <Contracts.GenericReference>();
            GroupCollection groups = new GroupCollection(clusterID);
            int             i;


            if (RestApi.GroupClusterOperationAllowed(ArenaContext.Current.Person.PersonID, clusterID, OperationType.View) == false)
            {
                throw new Exception("Access denied.");
            }

            list.Start = start;
            list.Max   = max;
            list.Total = groups.Count;
            list.Items = new List <Contracts.GenericReference>();
            for (i = start; i < groups.Count && (max <= 0 || i < (start + max)); i++)
            {
                list.Items.Add(new Contracts.GenericReference(groups[i]));
            }

            return(list);
        }