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

                    var itemIndex = Stewardesses.ToList().FindIndex(x => x.Id == _selectedStewardess.Id);
                    var item      = Stewardesses.ToList().ElementAt(itemIndex);
                    Stewardesses.RemoveAt(itemIndex);
                    item    = stewardessInput;
                    item.Id = _selectedStewardess.Id;
                    Stewardesses.Insert(itemIndex, item);
                    TbId.Text    = "Stewardess Id :" + item.Id;
                    TbFName.Text = "First name : " + item.FirstName;
                    TbLName.Text = "Last name : " + item.LastName;
                    TbBirth.Text = "Birth : " + item.DateOfBirth;
                }
            }
        }
예제 #2
0
        protected void SearchAsync()
        {
            List <Stewardess> temp = Stewardesses.ToList();

            Stewardesses.Clear();
            if (string.IsNullOrWhiteSpace(SearchFilter))
            {
                temp.Clear();
                UpdateDataAsync();
            }
            else
            {
                Stewardesses = new ObservableCollection <Stewardess>(temp.Where(s => s.FirstName.StartsWith(SearchFilter, StringComparison.CurrentCultureIgnoreCase) ||
                                                                                s.LastName.StartsWith(SearchFilter, StringComparison.CurrentCultureIgnoreCase)).ToList());
            }
            RaisePropertyChanged(nameof(Stewardesses));
        }