Example #1
0
            public static void Post_People(Rock.Client.Person person, int modifiedById, HttpRequest.RequestResult resultHandler)
            {
                // create a person object that can go up to rock, and copy the relavant data from the passed in arg
                Rock.Client.PersonEntity personEntity = PackagePersonForUpload(person);

                if (modifiedById > 0)
                {
                    personEntity.ModifiedAuditValuesAlreadyUpdated = true;
                    personEntity.CreatedByPersonAliasId            = modifiedById;
                    personEntity.ModifiedByPersonAliasId           = modifiedById;
                }

                RestRequest request = GetRockRestRequest(Method.POST);

                request.AddBody(personEntity);

                Request.ExecuteAsync(BaseUrl + EndPoint_People, request, resultHandler);
            }
Example #2
0
            const int ConnectionStatusTypeValueId = 67; // This represents "Web Prospect", and is the safest default to use.
            static Rock.Client.PersonEntity PackagePersonForUpload(Rock.Client.Person person)
            {
                // there are certain values that cannot be sent up to Rock, so
                // this will ensure that the 'person' object is setup for a clean upload to Rock.
                Rock.Client.PersonEntity newPerson = new Rock.Client.PersonEntity( );
                newPerson.CopyPropertiesFrom(person);
                newPerson.FirstName         = person.NickName;   //ALWAYS SET THE FIRST NAME TO NICK NAME
                newPerson.RecordTypeValueId = RecordTypeValueId; //ALWAYS SET THE RECORD TYPE TO PERSON

                // set the record / connection status values only if they aren't already set.
                if (newPerson.RecordStatusValueId == null)
                {
                    newPerson.RecordStatusValueId = RecordStatusTypeValueId;
                }

                if (newPerson.ConnectionStatusValueId == null)
                {
                    newPerson.ConnectionStatusValueId = ConnectionStatusTypeValueId;
                }

                return(newPerson);
            }