private async void BtnUpdate_OnClick(object sender, RoutedEventArgs e) { if (!isCreate) { var flight = ReadTextBoxesData(); if (flight != null && _selectedFlight != null) { try { await Service.Update(flight, _selectedFlight.Id); } catch { Info.Text = "Server error!"; } var itemIndex = Flights.ToList().FindIndex(x => x.Id == _selectedFlight.Id); var item = Flights.ToList().ElementAt(itemIndex); Flights.RemoveAt(itemIndex); item = flight; item.Id = _selectedFlight.Id; Flights.Insert(itemIndex, item); TbNumber.Text = "Number : " + item.Number; TbDep.Text = "Point of departure :" + item.PointOfDeparture; TbDepTime.Text = "Departure time :" + item.DepartureTime; TbDest.Text = "Destination :" + item.Destination; TbArrTime.Text = "Arrival time :" + item.ArrivelTime; TbTicket.Text = "Tickets : " + TicketsId(item); } } }
private void DeleteFlights() { int i = 0; while (i < Flights.Count) { if (!Flights[i].isActual) { Flights.RemoveAt(i); } else { break; } } }