private string UpdateProfile(IProvisioningModel model, IMainPresenter presenter) { string errorMessage = string.Empty; IMemberServices service = service = new MemberServices(ApplicationResource.BaseUrl, ApplicationResource.ApiVersion); service.SetProfileUrl = ApplicationResource.ActionSetProfile; service.UserAgentVersion = ApplicationResource.UserAgent; try { foreach (MemberListViewItemModel item in model.Members.Where(m => m.IsChecked).ToList()) { IServiceResponse response = service.SetProfile(new MemberData() { Email = item.Email, NewEmail = item.NewEmail, NewExternalId = item.NewExternalId }, model.AccessToken); if (response.StatusCode == HttpStatusCode.OK) { if (SyncContext != null) { SyncContext.Post(delegate { presenter.UpdateProgressInfo(string.Format("Updated profile for: {0}", item.Email)); }, null); } } else if ((response.Message).Contains("user_not_found")) { errorMessage = ErrorMessages.USER_NOT_FOUND; } else if ((response.Message).Contains("user_not_in_team")) { errorMessage = ErrorMessages.USER_NOT_IN_TEAM; } else { errorMessage = ErrorMessages.FAILED_TO_UPDATE_PROFILE; } } } catch(Exception) { //just catch the exception and return error message SyncContext.Post(delegate { presenter.ShowErrorMessage(ErrorMessages.FAILED_TO_UPDATE_PROFILE, ErrorMessages.DLG_DEFAULT_TITLE); presenter.UpdateProgressInfo(""); presenter.ActivateSpinner(false); presenter.EnableControl(true); }, null); } return errorMessage; }