public async void Delete(object sender, RoutedEventArgs e) { if (SaveButton.Visibility == Visibility.Visible) { SaveButton.Visibility = Visibility.Collapsed; } if (AddButton.Visibility == Visibility.Visible) { AddButton.Visibility = Visibility.Collapsed; } try { if (TextId.IsReadOnly) { TextId.IsReadOnly = false; } await _service.Delete(SelectedStewardesse.Id.ToString()); // refresh listView Stewardesses.Clear(); foreach (var airplaneType in await _service.LoadData()) { Stewardesses.Add(airplaneType); } } catch (Exception) { } }
protected void SearchAsync() { List <Stewardess> temp = Stewardesses.ToList(); Stewardesses.Clear(); if (string.IsNullOrWhiteSpace(SearchFilter)) { temp.Clear(); UpdateDataAsync(); } else { Stewardesses = new ObservableCollection <Stewardess>(temp.Where(s => s.FirstName.StartsWith(SearchFilter, StringComparison.CurrentCultureIgnoreCase) || s.LastName.StartsWith(SearchFilter, StringComparison.CurrentCultureIgnoreCase)).ToList()); } RaisePropertyChanged(nameof(Stewardesses)); }
public async void LoadData(object sender, RoutedEventArgs e) { if (SaveButton.Visibility == Visibility.Visible) { SaveButton.Visibility = Visibility.Collapsed; } if (AddButton.Visibility == Visibility.Visible) { AddButton.Visibility = Visibility.Collapsed; } Stewardesses.Clear(); foreach (var airplaneType in await _service.LoadData()) { Stewardesses.Add(airplaneType); } }
public async void Add(object sender, RoutedEventArgs e) { SelectedStewardesse.Id = 0; SelectedStewardesse.FirstName = TextFirstName.Text; SelectedStewardesse.LastName = TextLastName.Text; SelectedStewardesse.Birthdate = DateTime.Parse(TextBirthdate.Text); await _service.Create(SelectedStewardesse); AddButton.Visibility = Visibility.Collapsed; TextId.IsReadOnly = false; // refresh listView Stewardesses.Clear(); foreach (var airplaneType in await _service.LoadData()) { Stewardesses.Add(airplaneType); } }