public async void Delete() { Commands cmd = new Backend.Commands(); if (TMessageBox.Show("Are you sure you want to delete this account?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { while (true) { var res = cmd.AmISync(); if (res == SyncronizingStateEnum.Synced) { break; } else { HIOStaticValues.SyncOpration(); } } await UIService.Execute(async() => { Commands ic = new Commands(); ic.Delete(UserID); await Parent.LoadData(); }); Parent?.OnPropertyChanged(nameof(TAccountManagerViewModel.IsAllChecked)); } }
private async void Delete() { if (HIOStaticValues.CheckSyncingData()) { return; } if (TMessageBox.Show("Are you sure you want to delete these accounts?", "Confirm", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { Commands cmd = new Backend.Commands(); while (true) { var res = cmd.AmISync(); if (res == SyncronizingStateEnum.Synced) { break; } else { HIOStaticValues.SyncOpration(); } } await UIService.Execute(async() => { DataBase db = new DataBase(); foreach (var item in SourceItems.Where(t => t.IsChecked).ToArray()) { Commands ic = new Commands(); if (ic.Delete(item.UserID)) { App.Current.Dispatcher.BeginInvoke((Action)(() => { SourceItems.Remove(SourceItems.FirstOrDefault(i => i.UserID == item.UserID)); OnPropertyChanged(nameof(Items)); })); } } await LoadData(); }); OnPropertyChanged(nameof(IsAllChecked)); } }