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(SelectedPilot.Id.ToString()); // refresh listView Pilots.Clear(); foreach (var airplaneType in await _service.LoadData()) { Pilots.Add(airplaneType); } } catch (Exception) { } }
public void ResetPilots() { Pilots.Clear(); foreach (var p in Event.Instance.Pilots) Pilots.Add(p); RaisePropertyChanged("Pilots"); RaisePropertyChanged("Status"); }
public async Task Search() { Pilots.Clear(); List <Pilot> tempPilots = await PilotService.GetAll(); foreach (var item in tempPilots) { Pilots.Add(item); } }
protected void SearchAsync() { List <Pilot> temp = Pilots.ToList(); Pilots.Clear(); if (string.IsNullOrWhiteSpace(SearchFilter)) { temp.Clear(); UpdateDataAsync(); } else { Pilots = new ObservableCollection <Pilot>(temp.Where(s => s.FirstName.StartsWith(SearchFilter, StringComparison.CurrentCultureIgnoreCase) || s.LastName.StartsWith(SearchFilter, StringComparison.CurrentCultureIgnoreCase)).ToList()); } RaisePropertyChanged(nameof(Pilots)); }
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; } Pilots.Clear(); foreach (var airplaneType in await _service.LoadData()) { Pilots.Add(airplaneType); } }
public async void Add(object sender, RoutedEventArgs e) { SelectedPilot.Id = 0; SelectedPilot.FirstName = TextFirstName.Text; SelectedPilot.LastName = TextLastName.Text; SelectedPilot.Birthdate = DateTime.Parse(TextBirthdate.Text); SelectedPilot.Experience = int.Parse(TextExperience.Text); await _service.Create(SelectedPilot); AddButton.Visibility = Visibility.Collapsed; TextId.IsReadOnly = false; // refresh listView Pilots.Clear(); foreach (var airplaneType in await _service.LoadData()) { Pilots.Add(airplaneType); } }