예제 #1
0
        public static Booking GetBooking()
        {
            Booking booking = new Booking();

            Console.WriteLine(Constant.JourneyDetail);

            Console.Write(Constant.Date);
            booking.Date = Helper.ValidDate();

            Console.Write(Constant.Source);
            booking.SourceCityName = Helper.GetValidCity();;

            while (true)
            {
                Console.Write(Constant.Destination);
                booking.DestinationCityName = Helper.GetValidCity();
                if (booking.DestinationCityName != booking.SourceCityName)
                {
                    break;
                }
                else
                {
                    Console.WriteLine(Constant.InvalidValue);
                }
            }

            Console.Write(Constant.LandMark);
            booking.LandMark = Console.ReadLine();

            return(booking);
        }
예제 #2
0
        public static Places GetPlaces()
        {
            Places point = new Places();

            Console.Write(Constant.City);
            point.City = Helper.GetValidCity();
            return(point);
        }
예제 #3
0
        public static Ride GetRideDetail()
        {
            Console.Clear();
            Ride ride = new Ride();

            Console.Write(Constant.Date);
            ride.Date = Helper.ValidDate();

            ride.Car = GetCarDetails();

            Console.Write(Constant.Source);
            ride.SourceCityName = Helper.GetValidCity();

            while (true)
            {
                Console.Write(Constant.Destination);
                ride.DestinationCityName = Helper.GetValidCity();
                if (ride.DestinationCityName != ride.SourceCityName)
                {
                    break;
                }
                else
                {
                    Console.WriteLine(Constant.InvalidValue);
                }
            }

            Console.Write(Constant.LandMark);
            ride.LandMark = Console.ReadLine();

            Console.Write(Constant.NoOfViaPlaces);
            int number = Helper.ValidInteger();

            for (int count = 0; count < number; count++)
            {
                var places    = GetPlaces();
                var duplicate = ride.Points.FirstOrDefault(a => a.City == places.City);

                if (places.City != ride.DestinationCityName && places.City != ride.SourceCityName && duplicate == null)
                {
                    ride.Points.Add(places);
                }
                else
                {
                    Console.WriteLine(Constant.InvalidValue);
                    count--;
                }
            }

            return(ride);
        }
예제 #4
0
        public static Ride GetRideDetail()
        {
            Ride ride = new Ride();

            Console.Write(Constant.TravellingDate);
            ride.TravelDate = Helper.ValidDate();

            Console.Write(Constant.From);
            string city = Helper.GetValidCity();

            ride.From          = CitiesInfo.Cities.FirstOrDefault(a => a.City.Equals(city, StringComparison.InvariantCultureIgnoreCase));
            ride.TotalDistance = 0;

            Console.Write(Constant.LandMark);
            ride.From.LandMark = Console.ReadLine();

            while (true)
            {
                Console.Write(Constant.To);
                city    = Helper.GetValidCity();
                ride.To = CitiesInfo.Cities.FirstOrDefault(a => a.City.Equals(city, StringComparison.InvariantCultureIgnoreCase));

                var fromCityIndex = ViaPointsInfo.Points.IndexOf(ViaPointsInfo.Points.FirstOrDefault(a => a.FromCity == ride.From.City));
                var toCityIndex   = ViaPointsInfo.Points.IndexOf(ViaPointsInfo.Points.FirstOrDefault(a => a.ToCity == ride.To.City));
                int viaPointCount = toCityIndex - fromCityIndex + 1;
                if (viaPointCount > 0)
                {
                    for (int viaPoint = 0; viaPoint < viaPointCount; viaPoint++)
                    {
                        Point via = new Point();
                        via = ViaPointsInfo.Points[fromCityIndex + viaPoint];
                        ride.TotalDistance = ride.TotalDistance + via.Distance;
                        ride.ViaPoints.Add(via);
                    }
                    break;
                }
                else
                {
                    Console.WriteLine(Constant.InValidInput);
                }
            }

            Console.WriteLine(Constant.Distance + ride.TotalDistance);

            Console.Write(Constant.TravellingRate);
            ride.RatePerKM = Helper.GetValidFloat();

            return(ride);
        }
예제 #5
0
        public static SearchRideRequest GetBooking()
        {
            SearchRideRequest booking = new SearchRideRequest();

            Console.Write(Constant.TravellingDate);
            booking.TravelDate = Helper.ValidDate();

            Console.Write(Constant.From);
            string city = Helper.GetValidCity();

            booking.From = CitiesInfo.Cities.FirstOrDefault(a => a.City.Equals(city, StringComparison.InvariantCultureIgnoreCase));
            float TravellingDistance = 0;

            Console.Write(Constant.LandMark);
            booking.From.LandMark = Console.ReadLine();

            while (true)
            {
                Console.Write(Constant.To);
                city       = Helper.GetValidCity();
                booking.To = CitiesInfo.Cities.FirstOrDefault(a => a.City.Equals(city, StringComparison.InvariantCultureIgnoreCase));

                var fromCityIndex = ViaPointsInfo.Points.IndexOf(ViaPointsInfo.Points.FirstOrDefault(a => a.FromCity == booking.From.City));
                var toCityIndex   = ViaPointsInfo.Points.IndexOf(ViaPointsInfo.Points.FirstOrDefault(a => a.ToCity == booking.To.City));
                int viaPointCount = toCityIndex - fromCityIndex + 1;
                if (viaPointCount > 0)
                {
                    for (int viaPoint = 0; viaPoint < viaPointCount; viaPoint++)
                    {
                        Point via = new Point();
                        via = ViaPointsInfo.Points[fromCityIndex + viaPoint];
                        TravellingDistance = TravellingDistance + via.Distance;
                    }
                    break;
                }
                else
                {
                    Console.WriteLine(Constant.InValidInput);
                }
            }

            Console.WriteLine(Constant.Distance + TravellingDistance);
            Console.ReadKey();
            return(booking);
        }