static void TryUpdatePerson(bool isNewPerson, Rock.Client.Person person, bool isNewPhoneNumber, Rock.Client.PhoneNumber phoneNumber, List <KeyValuePair <string, string> > attributes, MemoryStream personImage, HttpRequest.RequestResult resultHandler) { // if they're a new person, flag them as a pending visitor. if (isNewPerson == true) { person.RecordStatusValueId = Settings.Rock_RecordStatusValueId_Pending; person.ConnectionStatusValueId = Settings.Rock_ConnectionStatusValueId_Visitor; } ApplicationApi.UpdateOrAddPerson(person, isNewPerson, Config.Instance.CurrentPersonAliasId, delegate(System.Net.HttpStatusCode statusCode, string statusDescription) { if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true) { // was this a new person? if (isNewPerson == true) { // then we need to get their profile so we know the ID to use for updating the rest of their stuff. TryGetNewlyCreatedProfile(person, isNewPhoneNumber, phoneNumber, attributes, personImage, resultHandler); } else { // now update pending attributes. foreach (KeyValuePair <string, string> attribValue in attributes) { // just fire and forget these values. FamilyManagerApi.UpdateOrAddPersonAttribute(person.Id, attribValue.Key, attribValue.Value, null); } // are we deleting an existing number? if (string.IsNullOrWhiteSpace(phoneNumber.Number) == true && isNewPhoneNumber == false) { TryDeleteCellPhone(person, phoneNumber, personImage, resultHandler); } // are we updating or adding an existing? else if (string.IsNullOrWhiteSpace(phoneNumber.Number) == false) { TryUpdateCellPhone(person, isNewPhoneNumber, phoneNumber, personImage, resultHandler); } else { TryUpdateProfilePic(person, personImage, resultHandler); } } } else { // error resultHandler(statusCode, statusDescription); } }); }