Exemplo n.º 1
0
        private void SaveFlight()
        {
            if (SelectedTrip != null && SelectedDate != null && Passengers.Count != 0)
            {
                List <PassengersInFlightModel> passList = new List <PassengersInFlightModel>(Passengers);
                Passengers.Clear();
                foreach (var p in passList)
                {
                    p.Date = SelectedDate.ToShortDateString();
                    PassengersInFlightModel pass = PassengersViewModel.AddNewPassenger(p);
                    Passengers.Add(pass);
                }

                FlightsViewModel.NewFlight = new TripModel(SelectedTrip.TripNumber, SelectedDate.ToShortDateString(), SelectedTrip.AirwayCompany, SelectedTrip.Plane, SelectedTrip.TownFrom, SelectedTrip.TownTo, SelectedTrip.DepTime, SelectedTrip.ArrTime, null, Passengers);
            }
            else if (SelectedTrip == null)
            {
                MessageBox.Show("Trip is not selected!");
            }
            else if (SelectedDate == null)
            {
                MessageBox.Show("Date for trip is not selected!");
            }
            else if (Passengers.Count == 0)
            {
                MessageBox.Show("Passengers list is empty! Please,add passengers.");
            }
            else
            {
                MessageBox.Show("Check entered data! Something is wrong.");
            }
        }
Exemplo n.º 2
0
        private void AddPassenger()
        {
            PassengersInFlightModel NewPassenger = PassengersViewModel.AddNewPassenger(SelectedTrip, "newFlight");

            if (NewPassenger != null)
            {
                int n = Trips.IndexOf(SelectedTrip);
                Trips[n].PassengersList.Add(NewPassenger);
            }
        }
Exemplo n.º 3
0
 private void EditPassengerData()
 {
     if (SelectedPassenger != null)
     {
         PassengersInFlightModel newData = PassengersViewModel.EditPassengerData(SelectedPassenger, SelectedTrip, "new flight");
         newData.Id   = SelectedPassenger.Id;
         newData.Date = SelectedPassenger.Date;
         int n = Trips.IndexOf(SelectedTrip);
         int m = Trips[n].PassengersList.IndexOf(SelectedPassenger);
         Trips[n].PassengersList.RemoveAt(m);
         Trips[n].PassengersList.Insert(m, newData);
     }
 }
Exemplo n.º 4
0
 private void FillInPassengersCollection()
 {
     Passengers = PassengersViewModel.GetAllPassengers();
     if (PassengersInFlight != null)
     {
         PassengersInFlight.ForEach(p =>
         {
             if (Passengers.Contains(p.PassengerName))
             {
                 Passengers.Remove(p.PassengerName);
             }
         });
     }
 }