private async void BtnUpdate_OnClick(object sender, RoutedEventArgs e) { if (!isCreate) { var pilotInput = ReadTextBoxesData(); if (pilotInput != null && _selectedCrew != null) { try { await Service.Update(pilotInput, _selectedCrew.Id); } catch { Info.Text = "Server error!"; } var itemIndex = Crews.ToList().FindIndex(x => x.Id == _selectedCrew.Id); var item = Crews.ToList().ElementAt(itemIndex); Crews.RemoveAt(itemIndex); item = pilotInput; item.Id = _selectedCrew.Id; Crews.Insert(itemIndex, item); TbId.Text = "Crew Id :" + item.Id; TbPilot.Text = "Pilot Id : " + item.PilotId; TbStewardess.Text = "Stewardesses : " + StewardessesId(item); } } }
private async void AddCrew() { try { var result = await _service.AddAsync(SelectedCrew); Crews.Insert(0, result); } catch (System.InvalidOperationException ex) { await _dialogService.ShowMessage(ex.Message, "Error"); } }