protected async void ListContactsCommand_Click(object sender, EventArgs e) { var signInUserId = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; AuthenticationHelper authenticationHelper = new AuthenticationHelper(); authenticationHelper.EnsureAuthenticationContext(new ADALTokenCache(signInUserId)); ContactsHelper contactsHelper = new ContactsHelper(authenticationHelper); var contacts = await contactsHelper.GetContacts(); List <String> results = new List <String>(); commandResult.Text = String.Format("Found {0} contacts! Showing first 10, if any.", contacts.Count()); foreach (var item in contacts.Take(10)) { results.Add(String.Format( "Name: {0} - Email: {1}", !String.IsNullOrEmpty(item.DisplayName) ? item.DisplayName : String.Empty, item.EmailAddresses != null ? item.EmailAddresses.First().Address : String.Empty)); } resultsList.DataSource = results; resultsList.DataBind(); }
public void DeleteContact() { if (CurrentContact == null) { return; } var messageBoxResult = MessageBox.Show(AppResources.ConfirmDeleteContact, AppResources.Confirm, MessageBoxButton.OKCancel); if (messageBoxResult != MessageBoxResult.OK) { return; } IsWorking = true; MTProtoService.DeleteContactAsync( CurrentContact.ToInputUser(), result => { IsWorking = false; EventAggregator.Publish(result.User); RaiseImportStatusChanged(new ImportEventArgs { Imported = false }); ContactsHelper.DeleteContactAsync(StateService, CurrentContact.Id); }, error => { IsWorking = false; Execute.ShowDebugMessage("contacts.deleteContact error: " + error); }); }
private void GetOwnerInfo() { try { if (PermissionsHelper.HasPermission(this, ConstantsAndTypes.AppPermission.ReadContacts) && PermissionsHelper.PermissionGranted(this, ConstantsAndTypes.AppPermission.ReadContacts)) { ContactsHelper contactHelper = new ContactsHelper(this); if (contactHelper.ReadProfile()) { string ownerUri = contactHelper.DeviceOwner.ThumbnailUri; string ownerFirstName = contactHelper.DeviceOwner.FirstName; string ownerSurname = contactHelper.DeviceOwner.Surname; if (_ownerThumb != null) { if (!string.IsNullOrEmpty(ownerUri)) { ImageryHelper imageHelper = new ImageryHelper(this, _ownerThumb); imageHelper.GetImageFromStringUri(contactHelper.DeviceOwner.ThumbnailUri); } else { _ownerThumb.SetImageResource(Resource.Drawable.ic_launcher); } } if (_ownerWelcome != null) { if (!(string.IsNullOrEmpty(ownerFirstName) || string.IsNullOrEmpty(ownerSurname))) { _ownerWelcome.Text = GetString(Resource.String.WelcomeMindYourMood) + " " + contactHelper.DeviceOwner.FirstName + " " + contactHelper.DeviceOwner.Surname; } else { _ownerWelcome.Text = GetString(Resource.String.WelcomeMindYourMoodNoContacts); } } } } else { if (_ownerWelcome != null) { _ownerWelcome.Text = GetString(Resource.String.WelcomeMindYourMoodNoContacts); } if (_ownerThumb != null) { _ownerThumb.SetImageResource(Resource.Drawable.ic_launcher); } } } catch (Exception e) { Log.Error(TAG, "GetOwnerInfo: Exception - " + e.Message); if (GlobalData.ShowErrorDialog) { ErrorDisplay.ShowErrorAlert(this, e, GetString(Resource.String.ErrorMainGetOwnerInfo), "MainActivity.GetOwnerInfo"); } } }
public void Handle(TLUpdateUserPhoto update) { //threadpool var userId = update.UserId; var contact = CacheService.GetUser(userId) as TLUserContact; if (contact != null) { ContactsHelper.UpdateContactAsync(_fileManager, StateService, contact); } }
public void Handle(TLUpdateUserPhoto update) { //threadpool var userId = update.UserId; var userBase = CacheService.GetUser(userId); if (userBase != null && userBase.IsContact) { ContactsHelper.UpdateContactAsync(DownloadFileManager, StateService, userBase); } }
public IHttpActionResult GetContact(string id) { var helper = new ContactsHelper(); var result = helper.GetContactIdByObjectId(id); if (result == 0) { return(NotFound()); } return(Ok(result)); }
public IHttpActionResult GetContact(int id) { var helper = new ContactsHelper(); var result = helper.GetContact(id); if (result == null) { return(NotFound()); } return(Ok(result)); }
public void AddContact() { if (CurrentContact == null) { return; } if (!HasPhone) { return; } var userPhone = new TLString(Phone); if (TLString.IsNullOrEmpty(userPhone)) { return; } IsWorking = true; ImportContactAsync(CurrentContact, userPhone, MTProtoService, result => { if (result.Users.Count > 0) { EventAggregator.Publish(new TLUpdateContactLink24 { UserId = result.Users[0].Id, MyLink = new TLContactLink(), ForeignLink = new TLContactLinkUnknown() }); var userBase = result.Users[0]; if (userBase != null && userBase.IsContact) { ContactsHelper.CreateContactAsync(_fileManager, StateService, userBase); } RaiseImportStatusChanged(new ImportEventArgs { Imported = true }); } BeginOnUIThread(() => { IsWorking = false; NotifyOfPropertyChange(() => HasPhone); }); }, error => BeginOnUIThread(() => { IsWorking = false; Execute.ShowDebugMessage("contacts.importContacts error " + error); })); }
public IHttpActionResult GetContacts(int id) { Contact contact = db.Contacts.Find(id); if (contact != null) { ContactsHelper Customer = new ContactsHelper(); IEnumerable <Contact> contactsList = Customer.GetContactsList(id); return(Ok(contactsList)); } return(BadRequest()); }
public void AddContact() { if (CurrentContact == null) { return; } if (!HasPhone) { return; } var userPhone = new TLString(Phone); if (TLString.IsNullOrEmpty(userPhone)) { return; } IsWorking = true; ImportContactAsync(CurrentContact, userPhone, MTProtoService, result => { IsWorking = false; if (result.Users.Count > 0) { EventAggregator.Publish(result.Users[0]); RaiseImportStatusChanged(new ImportEventArgs { Imported = true }); var contact = result.Users[0] as TLUserContact; if (contact != null) { EventAggregator.Publish(new AddedToContactsEventArgs { Contact = contact }); ContactsHelper.CreateContactAsync(_fileManager, StateService, contact); } } }, error => { IsWorking = false; Execute.ShowDebugMessage("contacts.importContacts error " + error); }); }
public void DeleteContact() { if (CurrentContact == null) { return; } var messageBoxResult = MessageBox.Show(AppResources.ConfirmDeleteContact, AppResources.Confirm, MessageBoxButton.OKCancel); if (messageBoxResult != MessageBoxResult.OK) { return; } IsWorking = true; MTProtoService.DeleteContactAsync( CurrentContact.ToInputUser(), result => { var link24 = result as TLLink24; if (link24 != null) { EventAggregator.Publish(new TLUpdateContactLink24 { UserId = link24.User.Id, MyLink = link24.MyLink, ForeignLink = link24.ForeignLink }); } RaiseImportStatusChanged(new ImportEventArgs { Imported = false }); ContactsHelper.DeleteContactAsync(StateService, CurrentContact.Id); BeginOnUIThread(() => { IsWorking = false; NotifyOfPropertyChange(() => HasPhone); }); }, error => BeginOnUIThread(() => { IsWorking = false; Execute.ShowDebugMessage("contacts.deleteContact error: " + error); })); }
public ActionResult PlayWithContacts() { var contacts = ContactsHelper.ListContacts(); try { var photo = ContactsHelper.GetContactPhoto(contacts[0].Id); } catch (Exception) { // Something wrong while getting the thumbnail, // We will have to handle it properly ... } contacts[0].PersonalNotes += String.Format("Modified on {0}", DateTime.Now); var updatedContact = ContactsHelper.UpdateContact(contacts[0]); var addedContact = ContactsHelper.AddContact(new Models.Contact { GivenName = "Michael", DisplayName = "Michael Red", EmailAddresses = new List <Models.UserInfo>( new Models.UserInfo[] { new Models.UserInfo { Address = "*****@*****.**", Name = "Michael Red", } }), CompanyName = "Sample Company", }); ContactsHelper.DeleteContact(addedContact.Id); return(View("Index")); }
public async Task <ActionResult> ListMyContacts() { HomeViewModel model = new HomeViewModel(); var signInUserId = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; AuthenticationHelper authenticationHelper = new AuthenticationHelper(); authenticationHelper.EnsureAuthenticationContext(new ADALTokenCache(signInUserId)); ContactsHelper contactsHelper = new ContactsHelper(authenticationHelper); var contacts = await contactsHelper.GetContacts(); model.Office365ActionResult = String.Format("Found {0} contacts! Showing first 10, if any.", contacts.Count()); foreach (var item in contacts.Take(10)) { model.Items.Add(String.Format( "Name: {0} - Email: {1}", !String.IsNullOrEmpty(item.DisplayName) ? item.DisplayName : String.Empty, item.EmailAddresses != null ? item.EmailAddresses.First().Address : String.Empty)); } return(View("UseOffice365API", model)); }
public AddressBookExport(WikiMedia wiki, ContactsHelper contacts) { InitializeComponent(); this.wiki = wiki; this.contacts = contacts; }
public void Done() { if (IsWorking) { return; } if (string.IsNullOrEmpty(FirstName) && string.IsNullOrEmpty(LastName)) { return; } var user = CurrentItem as TLUserBase; if (user == null) { return; } if (user is TLUserForeign || user is TLUserDeleted || user is TLUserEmpty) { return; } if (user.FirstName.ToString() != FirstName || user.LastName.ToString() != LastName) { user.ExtendedInfo = new TLUserExtendedInfo(); user.ExtendedInfo.FirstName = new TLString(FirstName ?? ""); user.ExtendedInfo.LastName = new TLString(LastName ?? ""); } else { user.ExtendedInfo = null; } IsWorking = true; MTProtoService.ImportContactsAsync( new TLVector <TLInputContactBase> { new TLInputContact { ClientId = new TLLong(0), FirstName = new TLString(FirstName), LastName = new TLString(LastName), Phone = user.Phone } }, new TLBool(false), importedContacts => { IsWorking = false; user.NotifyOfPropertyChange("FullName"); var dialog = CacheService.GetDialog(new TLPeerUser { Id = user.Id }); if (dialog != null) { dialog.With = user; dialog.NotifyOfPropertyChange("With"); } var contact = user as TLUserContact; if (contact != null) { ContactsHelper.UpdateContactAsync(_fileManager, StateService, contact); } //EventAggregator.Publish(statedMessage.Message); BeginOnUIThread(() => NavigationService.GoBack()); }, error => { IsWorking = false; }); }