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 async void AddFlight() { try { var result = await _service.AddAsync(SelectedFlight); Flights.Insert(0, result); } catch (System.InvalidOperationException ex) { await _dialogService.ShowMessage(ex.Message, "Error"); } }
// POST: api/flights public List <Flights> Post([FromBody] Flights flight) { return(Flights.Insert(flight)); }