public void DelItem() { Object temp = new object(); foreach (Window window in Application.Current.Windows) { if (window.GetType() == typeof(MainWindow)) { temp = (window as MainWindow).listboxItems.SelectedItem; } } if (temp != null) { if (temp is Phone) { Phones.Remove((Phone)temp); } else if (temp is Laptop) { Laptops.Remove((Laptop)temp); } else if (temp is TV) { TVs.Remove((TV)temp); } SaveChanges(); } }
private async void setPhones() { for (var i = Phones.Count - 1; i >= 0; i--) { var pair = Phones[i]; if (pair.Key.Equals("Home")) { Phones.Remove(pair); } else if (pair.Key.Equals("Mobile")) { Phones.Remove(pair); } else if (pair.Key.Equals("Work")) { Phones.Remove(pair); } } if (HomePhoneEntered) { Phones.Add(new KeyValuePair <string, string>("Home", Prospect.HomePhoneNumber.Phone)); } if (MobilePhoneEntered) { Phones.Add(new KeyValuePair <string, string>("Mobile", Prospect.MobilePhoneNumber.Phone)); } if (WorkPhoneEntered) { Phones.Add(new KeyValuePair <string, string>("Work", Prospect.WorkPhoneNumber.Phone)); } await RaisePropertyChanged(() => Phones); }
private void Remove(object phoneObj) { var phone = phoneObj as PhoneViewModel; if (phone == null) { return; } Phones.Remove(phone); }
private void SetupDeleteMethod() { DeleteCommand = ReactiveCommand.CreateFromTask <Unit, Unit>( async dummy => { await _repository.RemoveAsync(SelectedPhone).ConfigureAwait(false); return(Unit.Default); }, this.WhenAny(vm => vm.SelectedPhone, change => change.Value != null)); DeleteCommand.ObserveOn(MainThreadScheduler).Subscribe(dummy => { Phones.Remove(SelectedPhone); }); DeleteCommand.ThrownExceptions.Subscribe(ex => { MessageBox.Show(ex.Message); }); }
public bool RemovePhone(Phone phone) { if (phone is null) { throw new EntityNotFoundException("User -> Phone"); } if (!Phones.Contains(phone)) { return(false); } Phones.Remove(phone); return(true); }
private void DeletePhone(bool isMobile) { void DeletePhone(Phone phone) { if (phone == null) { return; } Phones.Remove(phone); } DeletePhone(isMobile ? CurrentMobile : CurrentStatic); }
private void SaveContact(object obj) { if (contactClass.name == null || contactClass.name.Length == 0) { return; } contactClass ??= new ContactClass() { name = Name, address = Address, company = Company, nickName = NickName, Emails = this.selectedEmail, Phones = this.Phones }; var emptyPhones = Phones.Where(a => a.Phone.Length == 0).ToList(); foreach (var phone in emptyPhones) { Phones.Remove(phone); } var emptyEmails = selectedEmail.Where(a => a.Email.Length == 0).ToList(); foreach (var mail in emptyEmails) { selectedEmail.Remove(mail); } if (newContactFlag) { var contacts = ContactsClass.GetInstance; contacts.Add(contactClass); } NavigationService service = new NavigationService(); service.NavigateBack(); }
public void RemovePhone(Phone obj) { Phones.Remove(obj); }
public void DeletePhoneById(Guid id) { Phones.Remove(this.SearchPhoneById(id)); }