private void LoadContacts() { hasLoaded = false; OnPropertyChanged(nameof(HasContacts)); Contacts = BookSyncContactsHelper.BookSyncContacts.Where(w => !string.IsNullOrEmpty(w.FacebookUserId) && !w.InSync).ToList().OrderBy(o => o.PhoneName).ToList(); foreach (var contact in Contacts) { contact.IsSelected = true; } if (!Contacts.Any()) { Information = "There are no contacts to sync."; //populate the buttons text for unmatched and auto int unmatchedCount = BookSyncContactsHelper.BookSyncContacts.Count(c => string.IsNullOrEmpty(c.FacebookUserId)); SubInformation = $"You have {unmatchedCount} unmatched contact{(unmatchedCount > 1 ? "s" : string.Empty)}."; } hasLoaded = true; OnPropertyChanged(nameof(HasContactsToSync)); OnPropertyChanged(nameof(HasContacts)); OnPropertyChanged(nameof(HasUnMatchedContacts)); }
/// <summary> /// Adds the contact. /// </summary> /// <param name="contact">The contact.</param> public void AddContact(Contact contact) { if (Contacts == null) { Contacts = new List <Contact>(); } // If there are not default address, set this one as default if (Contacts.Where(x => x.IsDefault).Count() < 1) { contact.IsDefault = true; } //If this is the new default address if (contact.IsDefault) { foreach (Contact cont in Contacts) { cont.IsDefault = false; } } // If the address is not already in the list if (!Contacts.Any(x => x.PrimaryKey == contact.PrimaryKey)) { Contacts.Add(contact); contact.Person = this; } }
public virtual void AddContact(Contact contact) { if (Contacts.Any(x => x.Id == contact.Id)) { return; } ObservableContacts.Add(contact); }
public void TabSelectedChanged(int index) { TabIndex = index; Search(); IsEmpty = !(index == 0 ? Contacts != null && Contacts.Any() : Companies != null && Companies.Any()); }
/// <summary> /// Select all contacts /// </summary> private void SelectAllContact() { if (Contacts == null || !Contacts.Any()) { return; } Contacts.All(x => x.IsChecked = SelectAll); }
public override async void OnNavigatedTo(NavigationParameters parameters) { if (Contacts != null && Contacts.Any()) { return; } Contacts = await _dataService.GetAllContacts(); }
private void ExecuteAddPartisipantsCommand(object parametr) { bool res = Contacts.Any(x => x.Login == parametr as String); bool res2 = !SelectedConversation.ParticipantsLogin.Contains(parametr as String); if (res && res2) { model.InviteFriendToConversation(parametr as String, SelectedConversation.Id); } }
/// <summary> /// Refreshes the view. /// </summary> /// <param name="contacts">The contacts.</param> private void RefreshView(List <ContactModel> contacts) { Contacts.Clear(); foreach (var model in contacts) { Contacts.Add(new PersonViewModel(model)); } if (Contacts.Any()) { SetDataavailability(true); } }
public void AddContact(Contact contact) { if (!Contacts.Any(i => i.Id == contact.Id) || contact.Id == 0) { Contacts.Add(contact); } else { var c = Contacts.Where(i => i.Id == contact.Id).SingleOrDefault(); c = contact; } }
public bool IsValid() { if (!RolesIds?.Any() ?? true) { throw new Exception("O campo Permissões é obrigatório."); } if (!Contacts?.Any(contact => contact.ContactType == ContactType.Email) ?? true) { throw new Exception("Pelo um Email de contato deve ser informado."); } return(true); }
/// <summary> /// /// </summary> /// <returns></returns> public string ValidateDelete() { if (Contacts.Any()) { return("Partner has existing Contacts"); } if (Accounts.Any()) { return("Partner has existing Accounts"); } return(null); }
protected virtual void Dispose(bool disposing) { if (disposing && !_disposed) { if (Contacts.Any()) { foreach (var contact in Contacts) { _dbContext.DeleteAsync(contact).GetAwaiter().GetResult(); } } _disposed = true; } }
private void OnSaveSavedContacts() { if (!Contacts.Any(x => x.IsSelected == true)) { MessageBox.Show("Please select some contacts and then click on Save button."); } else { var selectedSavedContacts = Contacts.Where(x => x.IsSelected == true).Select(x => new SavedContact { Name = x.Contact.DisplayName, PhoneNumber = x.Contact.PhoneNumbers.ElementAt(0).PhoneNumber }).ToList(); SavedContacts = selectedSavedContacts; MessageBox.Show("Emergency contact list added successfully."); App.RootFrame.GoBack(); } }
public bool CanDelete(out string errorMessage) { errorMessage = string.Empty; if (Contacts.Any()) { errorMessage = "Partner has existing Contacts"; return(false); } if (Accounts.Any()) { errorMessage = "Partner has existing Accounts"; return(false); } return(true); }
public override void OnNavigatingTo(NavigationParameters parameters) { base.OnNavigatingTo(parameters); if (parameters.TryGetParam <string>(MainPage.AnotherParameter, out var paramString)) { Title = paramString; } if (!Contacts.Any()) { var contacts = _contactService.GetContacts(); foreach (var contact in contacts) { //TODO: opportunity to use enhanced observable collection from MVVM Helpers package? Contacts.Add(contact); } } }
protected override void ProcessRecord() { if (Contacts != null) { if (Contacts.Count == 3 & Contacts.Any(x => x.ContactType == "Billing") & Contacts.Any(y => y.ContactType == "Admin") & Contacts.Any(z => z.ContactType == "Emergency")) { var company = new Company { DisplayName = DisplayName, Email = Email, ErpAddressNo = ERPAddressNo, BillingCurrency = BillingCurrency.ToString(), BusinessPhone = BusinessPhone, ChamberOfCommerceNo = ChamberOfCommerceNo, CompanyType = CompanyType.ToString(), Contacts = Contacts, Country = Country, CrmId = CRMId, LanguageId = Language.ToString(), Fax = Fax, Street1 = Street1, Street2 = Street2, LegalName = LegalName, PostalCode = PostalCode, Town = Town, VatNo = VatNo }; var job = Create(Connection, company); if (Wait) { WriteObject(WaitJobFinished(job.Id, Connection)); } else { WriteObject(job); } } } }
public void UsePaging() { Contacts.Clear(); Persons.Clear(); if (FilterEnabled) { var filterArray = _allContacts.Where(x => Convert.ToDateTime(x.From) >= DateIn && Convert.ToDateTime(x.To) <= DateOut && Convert.ToDateTime(x.To) .Subtract(Convert.ToDateTime(x.From)).Minutes > 10).ToArray(); // Фильтр контактов больше 10 минут var result = Paging(10, filterArray); // Итоговое отображение отфильтрованных данных foreach (var row in result) { Contacts.Add(row); } } else { var contacts = Paging(10, _allContacts); foreach (var row in contacts) { Contacts.Add(row); } } if (!Contacts.Any()) { _backCommand.Execute(null); return; } var persons = Paging(10, _allPersons); foreach (var row in persons) { Persons.Add(row); } }
public async Task GivenContactDetailsAlreadyExist(int active, int inactive) { if (!Contacts.Any()) { TargetId = Guid.NewGuid(); if (active > 0) { Contacts.AddRange(CreateContacts(active, true)); } if (inactive > 0) { Contacts.AddRange(CreateContacts(inactive, false)); } foreach (var note in Contacts) { await _dbContext.SaveAsync(note).ConfigureAwait(false); } } }
private bool HasChanges() { return(Contacts.Any(c => c.WasModelChanged)); }
public XmppSession( XmppClientEx xmppClient, IMapper mapper, MyViewModel myViewModel, Contacts contacts, IPresenceManager presenceManager, IAvatarStorage avatarStorage, IUserAvatarStorage userAvatarStorage) { this.xmppClient = xmppClient; this.mapper = mapper; this.viewModel = myViewModel; this.contacts = contacts; this.presenceManager = presenceManager; this.avatarStorage = avatarStorage; this.userAvatarStorage = userAvatarStorage; xmppClient.XmppSessionStateObserver.Subscribe(async state => { if (state == SessionState.Disconnected && SessionState != SessionState.Disconnected) { //Task.Run(() => DoReconnectAsync(Connect, TimeSpan.FromSeconds(30), 100)); } await SetSessionState(state); System.Diagnostics.Debug.WriteLine(state); }); xmppClient .XmppXElementStreamObserver .Where(el => el.OfType <MatrixPresence>() && el.Cast <MatrixPresence>().Type == MatrixPresenceType.Available && contacts.Any(c => c.Jid == el.Cast <MatrixPresence>().From.Bare) ) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(el => { // received online presence from a contact System.Diagnostics.Debug.WriteLine($"online presence from: {el.Cast<MatrixPresence>().From}"); var pres = el.Cast <MatrixPresence>(); var contact = contacts.FirstOrDefault(ct => ct.Jid == pres.From.Bare); var viewPres = mapper.Map <ViewModel.Presence>(pres); contact.Presences.AddOrReplace(viewPres, p => p.Resource == viewPres.Resource); }); xmppClient .XmppXElementStreamObserver .Where(el => el.OfType <MatrixPresence>() && el.Cast <MatrixPresence>().Type == MatrixPresenceType.Unavailable && el.Cast <MatrixPresence>().From != null && el.Cast <MatrixPresence>().From.Resource != null && contacts.Any(c => c.Jid == el.Cast <MatrixPresence>().From.Bare) ) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(el => { // received offline presence from a contact System.Diagnostics.Debug.WriteLine($"offline presence from: {el.Cast<MatrixPresence>().From}"); var pres = el.Cast <MatrixPresence>(); var contact = contacts.FirstOrDefault(ct => ct.Jid == pres.From.Bare); contact.Presences.Remove(p => p.Resource == pres.From.Resource); }); xmppClient .XmppXElementStreamObserver .Where(el => el.OfType <MatrixMessage>() && el.Cast <MatrixMessage>().Type == MatriXMessageType.Chat && el.Cast <MatrixMessage>().From != null && el.Cast <MatrixMessage>().Body != null ) .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(el => { var msg = el.Cast <MatrixMessage>(); Contact contact; // handle incoming chat message if (!viewModel.Chats.Any(c => c.Jid == msg.From.Bare)) { if (contacts.Contains(msg.From.Bare)) { contact = contacts[msg.From.Bare]; } else { contact = new Contact(msg.From.Bare); } viewModel.AddChatMenu(contact, false); } else { contact = contacts[msg.From.Bare]; } contact.LastMessageResource = msg.From.Resource; var viewMessage = mapper.Map <Message>(msg); viewMessage.Nickname = contact.Name; viewMessage.IsSelf = false; if (msg.Id != null) { viewMessage.Id = msg.Id; } viewModel.GetChatMenu(msg.From.Bare).Messages.Add(viewMessage); }); /* * <presence> * <show>away</show> * <status>Kann nicht chatten. Muss arbeiten.</status> * <priority>40</priority> * <c xmlns="http://jabber.org/protocol/caps" ver="r75qsgpbcZtkumlpddBcZZCeDco=" hash="sha-1" node="http://psi-im.org"/> * <x xmlns="vcard-temp:x:update"> * <photo>9b33b369b378be852b8487e23105dd4bd880a0f0</photo> * </x> * </presence> * */ }
public bool ShouldSerializeContacts() { return(Contacts.Any()); }
private bool SendEmailCommandCanExecute() { return(Contacts != null && Contacts.Any(contact => contact.IncludeInEmail)); }
public bool ShouldSerializeContacts() => Contacts.Any();
private void ValidateKeys(TextWriter logger, bool fixIfPossible) { //get all cobie objects as a flat list to avoid tens of thousands of recursive searches var all = Get <CobieObject>().ToArray(); //contacts are used in every single object so it is better to cache them and avoid tens of thousands of searches var defaultContact = GetDefaultContactKey(); var cache = new Dictionary <Type, CobieObject[]>(); foreach (var o in all) { foreach (var key in o.GetKeys().ToArray()) { CobieObject[] candidates; //use type cache to get first level of candidates if (!cache.TryGetValue(key.ForType, out candidates)) { candidates = all.Where(c => c.GetType() == key.ForType).ToArray(); cache.Add(key.ForType, candidates); } //filter by name candidates = candidates.Where(c => c.Name == key.Name).ToArray(); if (candidates.Length == 0) { logger.WriteLine("{0} key '{1}' from {2} '{3}' doesn't point to any object in the model.", GetSheetName(key.ForType, "UK2012"), key.Name, GetSheetName(o.GetType(), "UK2012"), o.Name); if (fixIfPossible) { var keyType = key.GetType().Name; switch (keyType) { //these two are the most frequent keys case "ContactKey": //set contact key to the default value if it is not set at all if (String.IsNullOrWhiteSpace(key.Name)) { ((ContactKey)key).Email = defaultContact.Email; } //create contact with this email address else { if (Contacts == null) { Contacts = new List <Contact>(); } if (Contacts.Any(c => c.Email == key.Name)) { break; } Contacts.Add(new Contact { Email = key.Name, CreatedOn = DateTime.Now, CreatedBy = GetDefaultContactKey() }); } break; default: //Delete the key otherwise. It doesn't make a sense if it doesn't point to any object in the model. o.RemoveKey(key); break; } } } if (candidates.Length > 1) { logger.WriteLine( "{0} key '{1}' from {2} '{3}' points to more than one object in the model. Ambiguous reference can't be fixed.", key.ForType.Name, key.Name, o.GetType().Name, o.Name); } } } }
public bool HasContacts() { return(Contacts.Any()); }
public ContactInfo AddContact(ContactInfo contact) { contact.ContactId = Contacts.Any() ? Contacts.Max(c => c.ContactId) + 1 : 1; Contacts.Add(contact); return(contact); }