Beispiel #1
0
        private void LoadFlights(IEnumerable <Flight> flights)
        {
            var now = DateTime.Now.ToUniversalTime().AddHours(1);

            foreach (var flight in flights)
            {
                double hoursSince = now.Subtract(flight.ScheduledTime).TotalHours;

                if (flight.Direction == Direction.Arrival)
                {
                    if (hoursSince > 1)
                    {
                        continue;
                    }
                    Arrivals.Add(flight);
                }
                else
                {
                    if (hoursSince > 0.25)
                    {
                        continue;
                    }
                    Departures.Add(flight);
                }
            }
        }
Beispiel #2
0
        private void SerialPort_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs args)
        {
            try
            {
                var res = _chronograph.Interpret(_serialPortManager.SerialPort);
                res.Order += _worksheetManager.Offset;
                var raceTimeViewModel = new RaceTimeViewModel(res)
                {
                    Resend = new GalaSoft.MvvmLight.Command.RelayCommand <RaceTimeViewModel>(x => SendRaceTime(x))
                };
                System.Windows.Application.Current.Dispatcher.Invoke(() =>
                {
                    if (res.Departure != null)
                    {
                        Departures.Add(raceTimeViewModel);
                        _writer.WriteLine($"1-{res.Order}-{res.Departure}");
                    }
                    else if (res.Arrival != null)
                    {
                        Arrivals.Add(raceTimeViewModel);
                        _writer.WriteLine($"2-{res.Order}-{res.Arrival}");
                    }
                });

                SendRaceTime(raceTimeViewModel);
            }
            catch (Exception ex)
            {
                // I said no crash !
                System.Windows.Application.Current.Dispatcher.Invoke(() =>
                {
                    Logs.Add(ex.Message);
                });
            }
        }
Beispiel #3
0
        public async Task <IEnumerable <Arrival> > GetArrivals()
        {
            IEnumerable <DbArrival> dbArrivals = await _repository.GetDbArrivals();

            foreach (DbArrival arrival in dbArrivals)
            {
                Arrivals.Add(arrival.ToDomainObject());
            }
            return(Arrivals);
        }
Beispiel #4
0
        private static void BookTaxi()
        {
            Console.WriteLine("\n");

            var arrivals = new Arrivals();

            var addNewParticipantCheckin = false;

            do
            {
                Console.WriteLine($" Nom du participant : ");
                string nameParticipant = Console.ReadLine();

                var isArrivalHourValid = false;
                do
                {
                    Console.WriteLine($" Heure d'arrivé à la gare du participant - le format hh : ");
                    int arrivalHourValue;

                    if (int.TryParse(Console.ReadLine(), out arrivalHourValue) &&
                        arrivalHourValue >= 0 &&
                        arrivalHourValue <= 23)
                    {
                        var arrivalHour = new ArrivalHour(arrivalHourValue);
                        var participant = new Participant(nameParticipant);

                        var arrival = new Arrival(arrivalHour, participant);
                        arrivals.Add(arrival);

                        isArrivalHourValid = true;
                    }
                    else
                    {
                        Console.WriteLine(" Heure d'arrivée incorrecte !");
                    }
                }while (isArrivalHourValid == false);

                Console.WriteLine("Voulez-vous ajouter un autre participant ? [O/N]");
                var responseAddNewParticipant = Console.ReadLine();

                if (responseAddNewParticipant.Equals("O"))
                {
                    addNewParticipantCheckin = true;
                }
                else
                {
                    addNewParticipantCheckin = false;
                }
            }while (addNewParticipantCheckin == true);

            taxiOrganizers.Add(new TaxiOrganizer(arrivals));

            Console.WriteLine("\n\n\n");
        }
Beispiel #5
0
        public void Should_book_one_taxi_for_two_arrival_on_15h()
        {
            //GIVEN
            var arrivalHour = new ArrivalHour(15);
            var arrivals    = new Arrivals();

            arrivals.Add(new Arrival(arrivalHour, new Participant("Thierry de Pauw")));
            arrivals.Add(new Arrival(arrivalHour, new Participant("Houssam")));

            //WHEN
            var booking = new TaxiOrganizer(arrivals).GetBookings();

            //THEN
            var passengersExpected = new List <Passenger>()
            {
                new Passenger("Thierry de Pauw"),
                new Passenger("Houssam")
            };

            Check.That(booking).IsEqualTo(new TaxiBooking(new Taxi("Taxi_15h"), "15", passengersExpected));
        }
Beispiel #6
0
        public void GetLast_should_return_last_arrival_time_when_two_same_arrivals_hour()
        {
            // GIVEN
            Participant participant1 = new Participant("Houssam");
            Participant participant2 = new Participant("Thierry de Pauw");

            ArrivalHour arrivalHour = new ArrivalHour(15);

            Arrival  arrival  = new Arrival(arrivalHour, participant1);
            Arrival  arrival2 = new Arrival(arrivalHour, participant2);
            Arrivals arrivals = new Arrivals();

            arrivals.Add(arrival);
            arrivals.Add(arrival2);

            // WHEN
            ArrivalHour lastArrival = arrivals.GetLastArrivalTime();

            // THEN
            Check.That(lastArrival).IsEqualTo(new ArrivalHour(15));
        }
Beispiel #7
0
 public void CreateArrival(Arrival arrival)
 {
     try
     {
         Task.Run(() => _repository.CreateArrival(arrival.ToDataEntity()));
         Arrivals.Add(arrival);
     }
     catch (Exception)
     {
         throw;
     }
 }
 private void LoadFlights(IEnumerable <Flight> flights)
 {
     foreach (var flight in flights)
     {
         if (flight.Direction == Direction.Arrival)
         {
             Arrivals.Add(flight);
         }
         else
         {
             Departures.Add(flight);
         }
     }
     IsBusy = false;
 }
Beispiel #9
0
        public void Should_book_one_taxi_for_one_arrival_on_12h()
        {
            //GIVEN
            var arrivals = new Arrivals();

            arrivals.Add(new Arrival(new ArrivalHour(12), new Participant("Thierry de Pauw")));

            //WHEN
            var booking = new TaxiOrganizer(arrivals).GetBookings();

            //THEN
            var expectedPassengers = new List <Passenger>
            {
                new Passenger("Thierry de Pauw")
            };

            Check.That(booking).IsEqualTo(new TaxiBooking(new Taxi("Taxi_12h"), "12", expectedPassengers));
        }
        private void AddNewFlight()
        {
            TripModel newFlight = FlightsViewModel.CreateNewFlight();

            if (newFlight != null)
            {
                if (newFlight.DepOrArrFlag.Equals("departure"))
                {
                    Departures.Add(newFlight);
                    SelectedFlight = Departures.Last();
                }
                else if (newFlight.DepOrArrFlag.Equals("arrival"))
                {
                    Arrivals.Add(newFlight);
                    SelectedFlight = Arrivals.Last();
                }
            }
        }
Beispiel #11
0
        public void Add(DateTime current, int departures, int arrivals)
        {
            if (Departures.Count > 23)
            {
                Departures.RemoveAt(0);
            }
            if (Arrivals.Count > 23)
            {
                Arrivals.RemoveAt(0);
            }
            if (Times.Count > 23)
            {
                Times.RemoveAt(0);
            }

            Departures.Add(departures);
            Arrivals.Add(arrivals);
            Times.Add($"{current.AddHours(-1d).ToString("HH")} - {current.ToString("HH\r\ndd.MM.yyyy")}");
        }
        private void SearchInFlights()
        {
            DepSearchExcludedItems.ForEach(d => { if (!Departures.Contains(d))
                                                  {
                                                      Departures.Add(d);
                                                  }
                                           });
            ArrSearchExcludedItems.ForEach(d => { if (!Arrivals.Contains(d))
                                                  {
                                                      Arrivals.Add(d);
                                                  }
                                           });

            DepSearchResultItems.Clear();
            ArrSearchResultItems.Clear();
            DepSearchExcludedItems.Clear();
            ArrSearchExcludedItems.Clear();

            DepSearchResultItems = Departures.Where(d =>
                                                    d.AirwayCompany.name.ToUpper().Contains(SearchText.ToUpper()) ||
                                                    d.AirwayCompany.ID_comp.ToString().Contains(SearchText) ||
                                                    d.DepTimeString.Contains(SearchText) ||
                                                    d.ArrTimeString.Contains(SearchText) ||
                                                    d.Date.Contains(SearchText) ||
                                                    d.Plane.ToUpper().Contains(SearchText.ToUpper()) ||
                                                    d.TownFrom.ToUpper().Contains(SearchText.ToUpper()) ||
                                                    d.TownTo.ToUpper().Contains(SearchText.ToUpper()) ||
                                                    d.TripNumber.ToString().Contains(SearchText)
                                                    ).ToList();

            ArrSearchResultItems = Arrivals.Where(d =>
                                                  d.AirwayCompany.name.ToUpper().Contains(SearchText.ToUpper()) ||
                                                  d.AirwayCompany.ID_comp.ToString().Contains(SearchText) ||
                                                  d.DepTimeString.Contains(SearchText) ||
                                                  d.ArrTimeString.Contains(SearchText) ||
                                                  d.Date.Contains(SearchText) ||
                                                  d.Plane.ToUpper().Contains(SearchText.ToUpper()) ||
                                                  d.TownFrom.ToUpper().Contains(SearchText.ToUpper()) ||
                                                  d.TownTo.ToUpper().Contains(SearchText.ToUpper()) ||
                                                  d.TripNumber.ToString().Contains(SearchText)
                                                  ).ToList();

            DepSearchExcludedItems = Departures.Where(d =>
                                                      !d.AirwayCompany.name.ToUpper().Contains(SearchText.ToUpper()) ||
                                                      !d.AirwayCompany.ID_comp.ToString().Contains(SearchText) ||
                                                      !d.DepTimeString.Contains(SearchText) ||
                                                      !d.ArrTimeString.Contains(SearchText) ||
                                                      !d.Date.Contains(SearchText) ||
                                                      !d.Plane.ToUpper().Contains(SearchText.ToUpper()) ||
                                                      !d.TownFrom.ToUpper().Contains(SearchText.ToUpper()) ||
                                                      !d.TownTo.ToUpper().Contains(SearchText.ToUpper()) ||
                                                      !d.TripNumber.ToString().Contains(SearchText)).ToList();
            Departures.Clear();

            ArrSearchExcludedItems = Arrivals.Where(d =>
                                                    !d.AirwayCompany.name.ToUpper().Contains(SearchText.ToUpper()) ||
                                                    !d.AirwayCompany.ID_comp.ToString().Contains(SearchText) ||
                                                    !d.DepTimeString.Contains(SearchText) ||
                                                    !d.ArrTimeString.Contains(SearchText) ||
                                                    !d.Date.Contains(SearchText) ||
                                                    !d.Plane.ToUpper().Contains(SearchText.ToUpper()) ||
                                                    !d.TownFrom.ToUpper().Contains(SearchText.ToUpper()) ||
                                                    !d.TownTo.ToUpper().Contains(SearchText.ToUpper()) ||
                                                    !d.TripNumber.ToString().Contains(SearchText)).ToList();
            Arrivals.Clear();

            DepSearchResultItems.ForEach(d => Departures.Add(d));
            ArrSearchResultItems.ForEach(a => Arrivals.Add(a));
        }
        private void SelectTrips()
        {
            List <TripModel> depList  = new List <TripModel>();
            List <TripModel> arrsList = new List <TripModel>();

            if (SelectedCity != "Not selected" && SelectedCompany != "Not selected")
            {
                FlightsViewModel.GetFlights(SelectedCity, SelectedCompany, ref depList, ref arrsList);
                foreach (var t in depList)
                {
                    Departures.Add(t);
                }
                if (Departures.Count == 1)
                {
                    SelectedFiltersDep = "Found " + Departures.Count + " flight " + " from " + SelectedCity + " by " + SelectedCompany + ".";
                }
                else
                {
                    SelectedFiltersDep = "Found " + Departures.Count + " flights " + " from " + SelectedCity + " by " + SelectedCompany + ".";
                }
                foreach (var t in arrsList)
                {
                    Arrivals.Add(t);
                }
                if (Arrivals.Count == 1)
                {
                    SelectedFiltersArr = "Found " + Arrivals.Count + " flight " + " to " + SelectedCity + " by " + SelectedCompany + ".";
                }
                else
                {
                    SelectedFiltersArr = "Found " + Arrivals.Count + " flights " + " to " + SelectedCity + " by " + SelectedCompany + ".";
                }
                SelectedFiltersVisibility = "Visible";
            }
            else if (SelectedCity == "Not selected" && SelectedCompany != "Not selected")
            {
                FlightsViewModel.GetFlights(null, SelectedCompany, ref depList, ref arrsList);
                foreach (var t in depList)
                {
                    Departures.Add(t);
                }
                if (Departures.Count == 1)
                {
                    SelectedFiltersDep = "Found " + Departures.Count + " departure " + " by " + SelectedCompany + ".";
                }
                else
                {
                    SelectedFiltersDep = "Found " + Departures.Count + " departures " + " by " + SelectedCompany + ".";
                }
                foreach (var t in arrsList)
                {
                    Arrivals.Add(t);
                }
                if (Arrivals.Count == 1)
                {
                    SelectedFiltersArr = "Found " + Arrivals.Count + " arrival " + " by " + SelectedCompany + ".";
                }
                else
                {
                    SelectedFiltersArr = "Found " + Arrivals.Count + " arrivals " + " by " + SelectedCompany + ".";
                }
                SelectedFiltersVisibility = "Visible";
            }
            else if (SelectedCity != "Not selected" && SelectedCompany == "Not selected")
            {
                FlightsViewModel.GetFlights(SelectedCity, null, ref depList, ref arrsList);
                foreach (var t in depList)
                {
                    Departures.Add(t);
                }
                if (Departures.Count == 1)
                {
                    SelectedFiltersDep = "Found " + Departures.Count + " flight " + " from " + SelectedCity + ".";
                }
                else
                {
                    SelectedFiltersDep = "Found " + Departures.Count + " flights " + " from " + SelectedCity + ".";
                }
                foreach (var t in arrsList)
                {
                    Arrivals.Add(t);
                }

                SelectedFiltersArr        = "Found " + Arrivals.Count + " flights " + " to " + SelectedCity + ".";
                SelectedFiltersVisibility = "Visible";
            }
            else
            {
                FlightsViewModel.GetFlights(null, null, ref depList, ref arrsList);
                foreach (var t in depList)
                {
                    Departures.Add(t);
                }
                foreach (var t in arrsList)
                {
                    Arrivals.Add(t);
                }
                SelectedFiltersVisibility = "Hidden";
            }
        }