protected override bool OnSaveCanExecute() { return((Friend != null) && (!Friend.HasErrors) && PhoneNumbers.All(pn => !pn.HasErrors) && HasChanges); }
protected override bool OnSaveCanExecute() { return(Friend != null && PhoneNumbers.All(p => !p.HasErrors) && !Friend.HasErrors && HasChange); }
protected override bool OnSaveCanExecute() { // TODO: Check if friend valid return(Friend != null && !Friend.HasErrors && PhoneNumbers.All(pn => !pn.HasErrors) && HasChanges); }
public override bool Equals(object obj) { if (obj is Contact c) { return(string.Equals(Name, c.Name) && PhoneNumbers.Count == c.PhoneNumbers.Count && PhoneNumbers.All(p => c.PhoneNumbers.Contains(p))); } return(false); }
protected override bool OnSaveCanExcute() { return(Friend != null && !Friend.HasErrors && HasChanges && PhoneNumbers.All(x => !x.HasErrors)); }
public void UnWrap(IContactInfoLocal contactInfo) { contactInfo.FirstName = FirstName; contactInfo.LastName = LastName; contactInfo.MiddleName = MiddleName; contactInfo.Company = Company; contactInfo.JobTitle = JobTitle; contactInfo.Note = Note; // Update phone numbers foreach (var item in PhoneNumbers) { if (string.IsNullOrWhiteSpace(item.Number)) { continue; } var target = contactInfo.PhoneNumbers.FirstOrDefault(t => t.Id == item.Id); if (target == null || item.Id < 0) { target = contactInfo.AddressBook.CreatePhoneNumber(); contactInfo.PhoneNumbers.Add(target); } item.UnWrap(target); } foreach (var item in contactInfo.PhoneNumbers.Where(x => PhoneNumbers.All(y => x.Id != y.Id) || string.IsNullOrWhiteSpace(x.Number)).ToArray()) { contactInfo.PhoneNumbers.Remove(item); } // Update emails foreach (var item in Emails) { if (string.IsNullOrWhiteSpace(item.Email)) { continue; } var target = contactInfo.Emails.FirstOrDefault(t => t.Id == item.Id); if (target == null || item.Id < 0) { target = contactInfo.AddressBook.CreateEmail(); contactInfo.Emails.Add(target); } item.UnWrap(target); } foreach (var item in contactInfo.Emails.Where(x => Emails.All(y => x.Id != y.Id) || string.IsNullOrWhiteSpace(x.Email)).ToArray()) { contactInfo.Emails.Remove(item); } // Update tags foreach (var item in Tags) { var target = contactInfo.Tags.FirstOrDefault(t => t.Id == item.Id); if (target != null) { continue; } target = _contactsManager.Tags.FirstOrDefault(x => x.Id == item.Id); if (target != null) { contactInfo.Tags.Add(target); } } foreach (var item in contactInfo.Tags.Where(x => Tags.All(y => x.Id != y.Id)).ToArray()) { contactInfo.Tags.Remove(item); } }