コード例 #1
0
ファイル: BaseShop.cs プロジェクト: greSvoI/ElectronicsStore
        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();
            }
        }
コード例 #2
0
 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);
 }
コード例 #3
0
        private void Remove(object phoneObj)
        {
            var phone = phoneObj as PhoneViewModel;

            if (phone == null)
            {
                return;
            }
            Phones.Remove(phone);
        }
コード例 #4
0
        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); });
        }
コード例 #5
0
ファイル: User.cs プロジェクト: KEMAL-YILDIRIM/Blog-net-core
        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);
        }
コード例 #6
0
        private void DeletePhone(bool isMobile)
        {
            void DeletePhone(Phone phone)
            {
                if (phone == null)
                {
                    return;
                }

                Phones.Remove(phone);
            }

            DeletePhone(isMobile
                ? CurrentMobile
                : CurrentStatic);
        }
コード例 #7
0
        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();
        }
コード例 #8
0
 public void RemovePhone(Phone obj)
 {
     Phones.Remove(obj);
 }
コード例 #9
0
ファイル: Person.cs プロジェクト: linguoliang/learning
 public void DeletePhoneById(Guid id)
 {
     Phones.Remove(this.SearchPhoneById(id));
 }