Esempio n. 1
0
        private async void BtnUpdate_OnClick(object sender, RoutedEventArgs e)
        {
            if (!isCreate)
            {
                var pilotInput = ReadTextBoxesData();
                if (pilotInput != null && _selectedPilot != null)
                {
                    try
                    {
                        await Service.Update(pilotInput, _selectedPilot.Id);
                    }
                    catch
                    {
                        Info.Text = "Server error!";
                    }

                    var itemIndex = Pilots.ToList().FindIndex(x => x.Id == _selectedPilot.Id);
                    var item      = Pilots.ToList().ElementAt(itemIndex);
                    Pilots.RemoveAt(itemIndex);
                    item    = pilotInput;
                    item.Id = _selectedPilot.Id;
                    Pilots.Insert(itemIndex, item);
                    TbId.Text    = "Pilot Id :" + item.Id;
                    TbFName.Text = "First name : " + item.FirstName;
                    TbLName.Text = "Last name : " + item.LastName;
                    TbBirth.Text = "Birth : " + item.DateOfBirth;
                    TbExp.Text   = "Experience : " + item.Experience;
                }
            }
        }