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(SelectedAirplaneType.Id.ToString()); // refresh listView AirplaneTypes.Clear(); foreach (var airplaneType in await _service.LoadData()) { AirplaneTypes.Add(airplaneType); } } catch (Exception) { } }
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; } AirplaneTypes.Clear(); foreach (var airplaneType in await _service.LoadData()) { AirplaneTypes.Add(airplaneType); } }
public async void Add(object sender, RoutedEventArgs e) { SelectedAirplaneType.Id = 0; SelectedAirplaneType.AirplaneModel = TextAirplaneModel.Text; SelectedAirplaneType.SeatsCount = int.Parse(TextSeatsCount.Text); SelectedAirplaneType.CarryingCapacity = int.Parse(TextCarryingCapacity.Text); await _service.Create(SelectedAirplaneType); AddButton.Visibility = Visibility.Collapsed; TextId.IsReadOnly = false; // refresh listView AirplaneTypes.Clear(); foreach (var airplaneType in await _service.LoadData()) { AirplaneTypes.Add(airplaneType); } }