public static void UpdateOrAddPhoneNumber(Rock.Client.Person person, Rock.Client.PhoneNumber phoneNumber, bool isNew, HttpRequest.RequestResult <Rock.Client.PhoneNumber> resultHandler) { // is it blank? if (string.IsNullOrEmpty(phoneNumber.Number) == true) { // if it's not new, we should delete an existing if (isNew == false) { ApplicationApi.DeleteCellPhoneNumber(phoneNumber, delegate(System.Net.HttpStatusCode statusCode, string statusDescription) { if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true) { // return the blank number back to them resultHandler(statusCode, statusDescription, phoneNumber); } }); } // otherwise, simply ignore it and say we're done. else { resultHandler(System.Net.HttpStatusCode.OK, "", phoneNumber); } } // not blank, so we're adding or updating else { // send it to the server ApplicationApi.AddOrUpdateCellPhoneNumber(person, phoneNumber, isNew, 0, delegate(System.Net.HttpStatusCode statusCode, string statusDescription) { if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true) { // if it was new, get it so we have its ID if (isNew == true) { ApplicationApi.GetPhoneNumberByGuid(phoneNumber.Guid, resultHandler); } else { // it's updated, so now just return what we updated. resultHandler(statusCode, statusDescription, phoneNumber); } } // something went wrong, so return. else { resultHandler(statusCode, statusDescription, null); } }); } }
static void TryDeleteCellPhone(Rock.Client.Person person, Rock.Client.PhoneNumber phoneNumber, MemoryStream personImage, HttpRequest.RequestResult resultHandler) { // remove the current number ApplicationApi.DeleteCellPhoneNumber(phoneNumber, delegate(System.Net.HttpStatusCode statusCode, string statusDescription) { if (Rock.Mobile.Network.Util.StatusInSuccessRange(statusCode) == true) { TryUpdateProfilePic(person, personImage, resultHandler); } else { resultHandler(statusCode, statusDescription); } }); }