Пример #1
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;

            //
            // 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;
        }
Пример #2
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);
        }