Exemple #1
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);
        }
Exemple #2
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);
        }
Exemple #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);
        }
Exemple #4
0
        public Contracts.ProfileMember GetProfileMember(int profileID, int personID)
        {
            ProfileMember member = new ProfileMember(profileID, personID);


            if (member.ProfileID == -1)
            {
                throw new Arena.Services.Exceptions.ResourceNotFoundException("Invalid profile ID");
            }

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

            return(new Contracts.ProfileMember(member));
        }
Exemple #5
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));
        }
Exemple #6
0
        public Contracts.Profile GetProfileInformation(int profileID)
        {
            Contracts.ProfileMapper mapper = new Contracts.ProfileMapper();
            Profile profile = new Profile(profileID);


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

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

            return(mapper.FromArena(profile));
        }
Exemple #7
0
        GetProfileMemberActivity(int profileID, int personID, int start, int max)
        {
            Contracts.GenericListResult <Contracts.ProfileMemberActivity> list = new Contracts.GenericListResult <Contracts.ProfileMemberActivity>();
            Profile   profile = new Profile(profileID);
            DataTable dt;
            int       i;


            //
            // Check if the profile exists.
            //
            if (profile.ProfileID == -1)
            {
                throw new Arena.Services.Exceptions.ResourceNotFoundException("Invalid profile ID");
            }

            //
            // Check if the user has access to work with the profile.
            //
            if (RestApi.ProfileOperationAllowed(ArenaContext.Current.Person.PersonID, profile.ProfileID, OperationType.View) == false)
            {
                throw new Exception("Access denied.");
            }

            dt         = new ProfileMemberActivityData().GetProfileMemberActivityDetails_DT(RestApi.DefaultOrganizationID(), profile.ProfileType, profile.Owner.PersonID, personID);
            list.Start = start;
            list.Max   = max;
            list.Items = new List <Contracts.ProfileMemberActivity>();
            for (i = 0; i < dt.Rows.Count; i++)
            {
                if (RestApi.ProfileOperationAllowed(ArenaContext.Current.Person.PersonID, Convert.ToInt32(dt.Rows[i]["profile_id"]), OperationType.View) == false)
                {
                    continue;
                }

                if (list.Total >= start && (max <= 0 ? true : list.Items.Count < max))
                {
                    list.Items.Add(new Contracts.ProfileMemberActivity(dt.Rows[i]));
                }
                list.Total += 1;
            }

            return(list);
        }
Exemple #8
0
        GetProfileMembers(int profileID, String statusID, int start, int max)
        {
            Contracts.GenericListResult <Contracts.ProfileMember> list = new Contracts.GenericListResult <Contracts.ProfileMember>();
            Profile profile = new Profile(profileID);
            int     i, nStatusID;


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

            try
            {
                nStatusID = Convert.ToInt32(statusID);
            }
            catch
            {
                nStatusID = -1;
            }

            profile.LoadMemberArray();
            list.Start = start;
            list.Max   = max;
            list.Total = 0;
            list.Items = new List <Contracts.ProfileMember>();

            for (i = 0; i < profile.Members.Count; i++)
            {
                if (nStatusID != -1 && profile.Members[i].Status.LookupID != nStatusID)
                {
                    continue;
                }

                if (list.Total >= start && (max <= 0 ? true : list.Items.Count < max))
                {
                    list.Items.Add(new Contracts.ProfileMember(profile.Members[i]));
                }
                list.Total += 1;
            }

            return(list);
        }
Exemple #9
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);
        }
Exemple #10
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);
        }
 public void RegisterHandlers(String baseUrl, RestApi api)
 {
 }
Exemple #12
0
        public Contracts.GenericListResult <Contracts.ProfileMember> GetPersonProfileMembership(int id, int type, string inactive, int start, int max)
        {
            Contracts.GenericListResult <Contracts.ProfileMember> list = new Contracts.GenericListResult <Contracts.ProfileMember>();
            ProfileCollection pmc = new ProfileCollection();
            bool activeOnly       = true;
            int  i;


            //
            // Check if they want to include inactive records.
            //
            try
            {
                if (Convert.ToInt32(inactive) == 1)
                {
                    activeOnly = false;
                }
            }
            catch { }

            //
            // Check general.
            //
            if (type == (int)Enums.ProfileType.Ministry && RestApi.PersonFieldOperationAllowed(ArenaContext.Current.Person.PersonID, PersonFields.Activity_Ministry_Tags, OperationType.View) == false)
            {
                throw new Exception("Access denied");
            }
            else if (type == (int)Enums.ProfileType.Serving && RestApi.PersonFieldOperationAllowed(ArenaContext.Current.Person.PersonID, PersonFields.Activity_Serving_Tags, OperationType.View) == false)
            {
                throw new Exception("Access denied");
            }
            else if (type != (int)Enums.ProfileType.Personal && type != (int)Enums.ProfileType.Ministry && type != (int)Enums.ProfileType.Serving)
            {
                throw new Exception("Access denied");
            }

            //
            // If they are requesting membership in their own personal profiles
            // then retrieve those, otherwise retrieve the general profile
            // information.
            //
            if (type == (int)Enums.ProfileType.Personal)
            {
                pmc.LoadMemberPrivateProfiles(RestApi.DefaultOrganizationID(), ArenaContext.Current.Person.PersonID, id, activeOnly);
            }
            else
            {
                pmc.LoadMemberProfiles(RestApi.DefaultOrganizationID(), (Enums.ProfileType)type, id, activeOnly);
            }

            list.Items = new List <Contracts.ProfileMember>();
            list.Start = start;
            list.Max   = max;
            foreach (Profile p in pmc)
            {
                if (RestApi.ProfileOperationAllowed(ArenaContext.Current.Person.PersonID, p.ProfileID, OperationType.View) == false)
                {
                    continue;
                }

                if (list.Total >= start && list.Items.Count < max)
                {
                    list.Items.Add(new Contracts.ProfileMember(new ProfileMember(p.ProfileID, id)));
                }
                list.Total += 1;
            }

            return(list);
        }
Exemple #13
0
        public Object GetProfileList(String profileID, String profileType, int start, int max, String fields)
        {
            ProfileCollection profiles = null;

            Contracts.ProfileMapper mapper = null;
            Contracts.GenericListResult <Contracts.Profile>          listP = new Contracts.GenericListResult <Contracts.Profile>();
            Contracts.GenericListResult <Contracts.GenericReference> listR = new Contracts.GenericListResult <Contracts.GenericReference>();
            int i;


            if (profileType != null)
            {
                profiles = new ProfileCollection();
                profiles.LoadChildProfiles(-1, RestApi.DefaultOrganizationID(), (Arena.Enums.ProfileType)Convert.ToInt32(profileType), ArenaContext.Current.Person.PersonID);
            }
            else if (profileID != null)
            {
                Profile profile;

                if (RestApi.ProfileOperationAllowed(ArenaContext.Current.Person.PersonID, Convert.ToInt32(profileID), OperationType.View) == false)
                {
                    throw new Exception("Access denied.");
                }

                profile  = new Profile(Convert.ToInt32(profileID));
                profiles = profile.ChildProfiles;
            }
            else
            {
                throw new Exception("Required parameters not provided.");
            }

            //
            // Sort the list of profiles and determine if we are going to
            // be returning references or full objects.
            //
            profiles.Sort(delegate(Profile p1, Profile p2) { return(p1.Name.CompareTo(p2.Name)); });
            mapper = (string.IsNullOrEmpty(fields) ? null : new Contracts.ProfileMapper(new List <string>(fields.Split(','))));

            //
            // Prepare the appropraite list object.
            //
            if (mapper != null)
            {
                listP.Start = start;
                listP.Max   = max;
                listP.Total = 0;
                listP.Items = new List <Contracts.Profile>();
            }
            else
            {
                listR.Start = start;
                listR.Max   = max;
                listR.Total = 0;
                listR.Items = new List <Contracts.GenericReference>();
            }
            for (i = 0; i < profiles.Count; i++)
            {
                if (RestApi.ProfileOperationAllowed(ArenaContext.Current.Person.PersonID, profiles[i].ProfileID, OperationType.View) == false)
                {
                    continue;
                }

                if (mapper != null)
                {
                    if (listP.Total >= start && (max <= 0 ? true : listP.Items.Count < max))
                    {
                        listP.Items.Add(mapper.FromArena(profiles[i]));
                    }
                    listP.Total += 1;
                }
                else
                {
                    if (listR.Total >= start && (max <= 0 ? true : listR.Items.Count < max))
                    {
                        listR.Items.Add(new Contracts.GenericReference(profiles[i]));
                    }
                    listR.Total += 1;
                }
            }

            return(mapper != null ? (Object)listP : (Object)listR);
        }
Exemple #14
0
 public void RegisterHandlers(String baseUrl, RestApi api)
 {
 }