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

                    var itemIndex = Aircrafts.ToList().FindIndex(x => x.Id == _selectedAircraft.Id);
                    var item      = Aircrafts.ToList().ElementAt(itemIndex);
                    Aircrafts.RemoveAt(itemIndex);
                    item    = pilotInput;
                    item.Id = _selectedAircraft.Id;
                    Aircrafts.Insert(itemIndex, item);
                    TbId.Text       = "Aircraft Id :" + item.Id;
                    TbName.Text     = "Name : " + item.Name;
                    TbType.Text     = "Type  Id : " + item.TypeId;
                    TbRelease.Text  = "Release date : " + item.ReleseDate;
                    TbLifetime.Text = "Lifetime : " + item.Lifetime;
                }
            }
        }