Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
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);
        }