示例#1
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            var result = await Service.GetAll();

            result.ForEach(x => Pilots.Add(x));
            lastId = Pilots.LastOrDefault().Id;
        }
        public async void Delete(object sender, RoutedEventArgs e)
        {
            if (SaveButton.Visibility == Visibility.Visible)
            {
                SaveButton.Visibility = Visibility.Collapsed;
            }

            if (AddButton.Visibility == Visibility.Visible)
            {
                AddButton.Visibility = Visibility.Collapsed;
            }

            try
            {
                if (TextId.IsReadOnly)
                {
                    TextId.IsReadOnly = false;
                }

                await _service.Delete(SelectedPilot.Id.ToString());

                // refresh listView
                Pilots.Clear();
                foreach (var airplaneType in await _service.LoadData())
                {
                    Pilots.Add(airplaneType);
                }
            }
            catch (Exception)
            {
            }
        }
示例#3
0
 private async void BtnCreate_OnClick(object sender, RoutedEventArgs e)
 {
     Canvas.Visibility = Visibility.Collapsed;
     if (isCreate)
     {
         var pilot = ReadTextBoxesData();
         if (pilot != null)
         {
             try
             {
                 await Service.Create(pilot);
             }
             catch
             {
                 Info.Text = "Server error!";
             }
             lastId++;
             pilot.Id = lastId;
             Pilots.Add(pilot);
             isCreate = false;
             CreateInfo();
             Info.Text = "Choose new action!";
         }
     }
     else
     {
         CreateInfo();
         isCreate  = true;
         Info.Text = "Info : Input data and press 'Create' ";
     }
 }
示例#4
0
        private void ImportPilot(string[] record)
        {
            if (Competitions.Count() == 0)
            {
                throw new InvalidOperationException("Pilot import is not allowed when no competitions are defined");
            }

            var number = int.Parse(record[1]);

            Pilot pilot;

            if (Pilots.Any(p => p.Number == number))
            {
                pilot = Pilots.First(p => p.Number == number);
            }
            else
            {
                if (Tasks.Count() > 0)
                {
                    throw new InvalidOperationException("Cannot add pilots when there are tasks defined");
                }

                pilot = new Pilot()
                {
                    Number = number
                };
                Pilots.Add(pilot);
            }

            pilot.Name    = record[2].Trim();
            pilot.Country = (record.Length > 3) ? record[3].Trim() : "";
            pilot.Balloon = (record.Length > 4) ? record[4].Trim() : "";
        }
示例#5
0
        private async void Create()
        {
            var created = await airportConnector.PilotEndpoint.Create(newPilot);

            Pilots.Add(created);
            newPilot = new Pilot();
            RaisePropertyChanged(() => Pilots);
            RaisePropertyChanged(() => NewPilot);
        }
示例#6
0
        public void ResetPilots()
        {
            Pilots.Clear();
            foreach (var p in Event.Instance.Pilots)
                Pilots.Add(p);

            RaisePropertyChanged("Pilots");
            RaisePropertyChanged("Status");
        }
示例#7
0
        private async void FillPilotsCollection()
        {
            var temp = await service.GetEntities();

            foreach (var item in temp)
            {
                Pilots.Add(item);
            }
        }
示例#8
0
 private void extractIds()
 {
     foreach (Uri filmUri in FilmUris)
     {
         Films.Add(extractId(filmUri));
     }
     foreach (Uri pilotUri in PilotUris)
     {
         Pilots.Add(extractId(pilotUri));
     }
 }
示例#9
0
        public async Task Search()
        {
            Pilots.Clear();

            List <Pilot> tempPilots = await PilotService.GetAll();

            foreach (var item in tempPilots)
            {
                Pilots.Add(item);
            }
        }
        private async void FillAdditionalCollections()
        {
            var pilots = await pilotService.GetEntities();

            foreach (var item in pilots)
            {
                Pilots.Add(item);
            }


            var stewardesses = await stewardessService.GetEntities();

            foreach (var item in stewardesses)
            {
                Stewardesses.Add(item);
            }
        }
        public async void LoadData(object sender, RoutedEventArgs e)
        {
            if (SaveButton.Visibility == Visibility.Visible)
            {
                SaveButton.Visibility = Visibility.Collapsed;
            }

            if (AddButton.Visibility == Visibility.Visible)
            {
                AddButton.Visibility = Visibility.Collapsed;
            }

            Pilots.Clear();
            foreach (var airplaneType in await _service.LoadData())
            {
                Pilots.Add(airplaneType);
            }
        }
        public async void Add(object sender, RoutedEventArgs e)
        {
            SelectedPilot.Id         = 0;
            SelectedPilot.FirstName  = TextFirstName.Text;
            SelectedPilot.LastName   = TextLastName.Text;
            SelectedPilot.Birthdate  = DateTime.Parse(TextBirthdate.Text);
            SelectedPilot.Experience = int.Parse(TextExperience.Text);

            await _service.Create(SelectedPilot);

            AddButton.Visibility = Visibility.Collapsed;
            TextId.IsReadOnly    = false;

            // refresh listView
            Pilots.Clear();
            foreach (var airplaneType in await _service.LoadData())
            {
                Pilots.Add(airplaneType);
            }
        }
示例#13
0
 public bool AddPilot(IPilot pilot)
 {
     Pilots.Add(pilot.Id, pilot);
     NotifySquadronChanges();
     return(true);
 }
示例#14
0
        private async void LoadPilots()
        {
            var result = await PilotService.GetAll();

            result.ForEach(x => Pilots.Add(x));
        }