コード例 #1
0
 /// <summary>
 /// Calculates the total cost for each travel schedule
 /// </summary>
 /// <param name="scheduleForTravel"></param>
 private void CalculateTotalCostForTravel(TravelSchedule scheduleForTravel)
 {
     foreach (Schedule s in scheduleForTravel.GetSchedules())
     {
         scheduleForTravel.TotalCostPerTicket += s.GetFlightCosts().FirstOrDefault().CostPerTicket;
     }
 }
コード例 #2
0
        /// <summary>
        /// Adds the search result for direct flights into the schedule for travel
        /// </summary>
        /// <param name="searchInformation"></param>
        /// <param name="scheduleCollection"></param>
        /// <param name="result"></param>
        /// <exception cref="DirectFlightsNotAvailableException">Throws the exception when direct flights are not available for given search information</exception>
        private void AddSearchResultForDirectFlights(SearchInfo searchInformation, Schedules scheduleCollection, SearchResult result)
        {
            TravelSchedule scheduleForTravel = null;

            foreach (Schedule s in scheduleCollection)
            {
                if (s.RouteInfo.FromCity.CityId == searchInformation.FromCity.CityId && s.RouteInfo.ToCity.CityId == searchInformation.ToCity.CityId)
                {
                    //Create a new TravelSchedule
                    scheduleForTravel = CreateTravelSchedule(ScheduleType.Direct);

                    //Add schedules to Travel Schedule
                    AddScheduleForTravel(scheduleForTravel, s);

                    //Compute total cost for the Travel Schedule
                    CalculateTotalCostForTravel(scheduleForTravel);

                    //Add the travel schedule defined to the search result
                    AddTravelScheduleToResult(scheduleForTravel, result);
                }
            }

            if (scheduleForTravel == null)
            {
                throw new DirectFlightsNotAvailableException("Direct Flights Not Available");
            }
        }
コード例 #3
0
 /// <summary>
 /// Adds the schedule to the travel schedule for connecting flights
 /// </summary>
 /// <param name="scheduleForTravel"></param>
 /// <param name="schedules"></param>
 private void AddScheduleForTravel(TravelSchedule scheduleForTravel, Schedules schedules)
 {
     foreach (Schedule s in schedules)
     {
         scheduleForTravel.AddSchedule(s);
     }
 }
コード例 #4
0
        /// <summary>
        /// Creates a travel schedule based on the type of schedule
        /// </summary>
        /// <param name="type"></param>
        /// <returns>Returns a TravelSchedule object for a given type</returns>
        private TravelSchedule CreateTravelSchedule(ScheduleType type)
        {
            TravelSchedule scheduleForTravel = new TravelSchedule();

            scheduleForTravel.Type = type;

            return(scheduleForTravel);
        }
コード例 #5
0
 protected void dlOuterOnward_ItemDataBound(object sender, RepeaterItemEventArgs e)
 {
     if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
     {
         TravelSchedule drv           = e.Item.DataItem as TravelSchedule;
         Repeater       innerDataList = e.Item.FindControl("dlInnerOnward") as Repeater;
         innerDataList.DataSource = drv.GetSchedules();
         innerDataList.DataBind();
     }
 }
コード例 #6
0
        /// <summary>
        /// Adds the search result for connecting flights in the schedule
        /// </summary>
        /// <param name="searchInformation"></param>
        /// <param name="scheduleCollection"></param>
        /// <param name="result"></param>
        /// <exception cref="ConnectingFlightsNotAvailableException">Throws the exception when connecting flights are not available for given search information</exception>
        private void AddSearchResultForConnectingFlights(SearchInfo searchInformation, Schedules scheduleCollection, SearchResult result)
        {
            Schedules      connectingSchedules = null;
            bool           isConnecting        = false;
            TravelSchedule scheduleForTravel   = null;

            foreach (Schedule s in scheduleCollection)
            {
                connectingSchedules = null;
                isConnecting        = false;

                if (s.RouteInfo.FromCity.CityId == searchInformation.FromCity.CityId && s.RouteInfo.ToCity.CityId != searchInformation.ToCity.CityId)
                {
                    //Create connecting schedules collection and add the current schedule
                    connectingSchedules = new Schedules();
                    connectingSchedules.AddSchedule(s);

                    isConnecting = FindFlightSchedule(searchInformation.ToCity, scheduleCollection, s, connectingSchedules);
                    if (isConnecting)
                    {
                        bool isValid = false;

                        foreach (Schedule sch in connectingSchedules)
                        {
                            isValid = CheckIfScheduleIsValid(s, searchInformation);
                            if (!isValid)
                            {
                                break;
                            }
                        }

                        if (isValid)
                        {
                            //Create a new TravelSchedule
                            scheduleForTravel = CreateTravelSchedule(ScheduleType.Connecting);

                            //Add schedules to Travel Schedule
                            AddScheduleForTravel(scheduleForTravel, connectingSchedules);

                            //Compute total cost for the Travel Schedule
                            CalculateTotalCostForTravel(scheduleForTravel);

                            //Add the travel schedule defined to the search result
                            AddTravelScheduleToResult(scheduleForTravel, result);
                        }
                    }
                }
            }

            if (scheduleForTravel == null)
            {
                throw new ConnectingFlightsNotAvailableException("Connecting Flights Not Available");
            }
        }
コード例 #7
0
        public static async Task <Tuple <TravelSchedule, ErrorModel> > GetScheduleForTerminal(int terminalId)
        {
            var terminals = new TravelSchedule();
            var errModel  = new ErrorModel();

            using (HttpClientHelper client = new HttpClientHelper())
            {
                await client.ProcessClientRequestAsync <TravelSchedule>(GigUrl.GetSchedule + terminalId, HttpMethod.Get, null, success =>
                {
                    terminals = success;
                }, error =>
                {
                    errModel = error;
                });
            }
            return(new Tuple <TravelSchedule, ErrorModel>(terminals, errModel));
        }
コード例 #8
0
        protected void btnBook_Click(object sender, EventArgs e)
        {
            int adults = Convert.ToInt32(Request.QueryString["adults"].ToString());

            int             td = Convert.ToInt16(Request.QueryString["td"].ToString());
            TravelDirection traveldirection = (TravelDirection)td;

            List <string> onwardids = new List <string>();

            for (int i = 0; i < hdnScheduleOnwardSelectedId.Value.Split('|').Length; i++)
            {
                onwardids.Add(hdnScheduleOnwardSelectedId.Value.Split('|')[i].ToString());
            }

            List <TravelSchedule> lstTravelSchedule = (List <TravelSchedule>)Session["flightbookingonwardresults"];
            List <Schedule>       resultonward      = (from t in lstTravelSchedule.SelectMany(schedule => schedule.GetSchedules())
                                                       where onwardids.Contains(t.ID.ToString())
                                                       select t).ToList();

            TravelSchedule objOnwardSchedule   = new TravelSchedule();
            decimal        OnwardCostPerTicket = 0;
            decimal        OnwardTotalCost     = 0;

            foreach (Schedule schedule in resultonward)
            {
                objOnwardSchedule.AddSchedule(schedule);
                OnwardCostPerTicket = OnwardCostPerTicket + schedule.GetFlightCosts().FirstOrDefault().CostPerTicket;
            }


            OnwardTotalCost = OnwardCostPerTicket * adults;

            FlightBooking flightbookingonward = new FlightBooking();

            flightbookingonward.NoOfSeats   = adults;
            flightbookingonward.BookingType = BookingTypes.Flight;
            FlightClass Class = new FlightClass();

            Class.ClassInfo           = (TravelClass)Enum.Parse(typeof(TravelClass), Request.QueryString["class"]);
            flightbookingonward.Class = Class;
            flightbookingonward.TravelScheduleInfo = objOnwardSchedule;
            flightbookingonward.DateOfJourney      = Convert.ToDateTime(Request.QueryString["depart_date"]);
            flightbookingonward.TotalCost          = OnwardTotalCost;

            if (Membership.GetUser() != null)
            {
                flightbookingonward.UserName = Membership.GetUser().UserName;
            }
            else
            {
                flightbookingonward.UserName = "******";
            }


            TravelBooking travelbooking = new TravelBooking();

            travelbooking.AddBookingForTravel(TravelDirection.OneWay, flightbookingonward);

            if (traveldirection == TravelDirection.Return)
            {
                List <string> retunrids = new List <string>();
                for (int i = 0; i < hdnScheduleReturnSelectedId.Value.Split('|').Length; i++)
                {
                    retunrids.Add(hdnScheduleReturnSelectedId.Value.Split('|')[i].ToString());
                }

                List <TravelSchedule> lstTravelScheduleReturn = (List <TravelSchedule>)Session["flightbookingreturnresults"];
                List <Schedule>       resultreturn            = (from t in lstTravelScheduleReturn.SelectMany(schedule => schedule.GetSchedules())
                                                                 where retunrids.Contains(t.ID.ToString())
                                                                 select t).ToList();

                TravelSchedule objReturnSchedule   = new TravelSchedule();
                decimal        ReturnTotalCost     = 0;
                decimal        ReturnCostPerTicket = 0;
                foreach (Schedule schedule in resultreturn)
                {
                    objReturnSchedule.AddSchedule(schedule);
                    ReturnCostPerTicket = ReturnCostPerTicket + schedule.GetFlightCosts().FirstOrDefault().CostPerTicket;
                }
                ReturnTotalCost = ReturnCostPerTicket * adults;

                FlightBooking flightbookingreturn = new FlightBooking();
                flightbookingreturn.NoOfSeats          = adults;
                flightbookingreturn.TravelScheduleInfo = objReturnSchedule;
                flightbookingreturn.DateOfJourney      = Convert.ToDateTime(Request.QueryString["return_date"]);
                flightbookingreturn.TotalCost          = ReturnTotalCost;

                if (Membership.GetUser() != null)
                {
                    flightbookingreturn.UserName = Membership.GetUser().UserName;
                }
                else
                {
                    flightbookingreturn.UserName = "******";
                }


                travelbooking.AddBookingForTravel(TravelDirection.Return, flightbookingreturn);
            }

            Session["travelbooking"] = travelbooking;

            Response.Redirect("~/booking/passengers.aspx");
        }
コード例 #9
0
 /// <summary>
 /// Adds the travel schedule to search result
 /// </summary>
 /// <param name="scheduleForTravel"></param>
 /// <param name="result"></param>
 private void AddTravelScheduleToResult(TravelSchedule scheduleForTravel, SearchResult result)
 {
     result.AddTravelSchedule(scheduleForTravel);
 }
コード例 #10
0
 /// <summary>
 /// Adds the schedule to the travel schedule for direct flight
 /// </summary>
 /// <param name="scheduleForTravel"></param>
 /// <param name="schedule"></param>
 private void AddScheduleForTravel(TravelSchedule scheduleForTravel, Schedule schedule)
 {
     scheduleForTravel.AddSchedule(schedule);
 }
コード例 #11
0
ファイル: SearchDAO.cs プロジェクト: Satishchitturi/HappyTrip
        /// <summary>
        /// Search for user booking history
        /// </summary>
        /// <param name="UserID"></param>
        /// <param name="BookingsFrom"></param>
        /// /// <param name="BookingsTo"></param>
        /// <returns>Returns the list of bookings between given dates</returns>
        public System.Collections.Generic.List <HappyTrip.Model.Entities.Transaction.FlightBooking> SearchUserBookings(string UserID, DateTime BookingsFrom, DateTime BookingsTo)
        {
            List <FlightBooking> lstBookings = null;

            try
            {
                string strSQL = "select bookings.BookingId, Bookings.BookingReferenceNo, bookings.BookingDate, bookings.TotalCost, bookings.IsCanceled, FlightBookings.DateOfJourney, f.CityId \"FromCityId\", f.CityName \"FromCity\", t.CityId \"ToCityId\",  t.CityName \"ToCity\", airlines.AirlineId, airlines.AirlineLogo, airlines.AirlineName, flights.FlightId, flights.FlightName, Routes.RouteId, Routes.Status, Schedules.ScheduleId from dbo.Bookings join dbo.FlightBookings on dbo.Bookings.BookingId = dbo.FlightBookings.BookingId join dbo.FlightBookingSchedules on dbo.Bookings.BookingId = dbo.FlightBookingSchedules.BookingId join dbo.Schedules on dbo.FlightBookingSchedules.ScheduleId = dbo.Schedules.ScheduleId join dbo.Routes on dbo.Schedules.RouteId = dbo.Routes.RouteId join dbo.Cities f on dbo.Routes.FromCityId = f.CityId join dbo.Cities t on dbo.Routes.ToCityId = t.CityId join dbo.Flights on dbo.Schedules.FlightId = dbo.Flights.FlightId join dbo.Airlines on dbo.Flights.AirlineId = dbo.Airlines.AirlineId join dbo.UserBookings on dbo.UserBookings.BookingId = dbo.Bookings.BookingId where dbo.UserBookings.UserId = '" + UserID + "' ";

                /* This temporary SQL can be used to fetch some results **************************/
                //strSQL = "select Bookings.BookingId, Bookings.BookingReferenceNo, bookings.BookingDate, bookings.TotalCost, bookings.IsCanceled, FlightBookings.DateOfJourney, f.CityId \"FromCityId\", f.CityName \"FromCity\", t.CityId \"ToCityId\",  t.CityName \"ToCity\", airlines.AirlineId, airlines.AirlineLogo, airlines.AirlineName, flights.FlightId, flights.FlightName, Routes.RouteId, Routes.Status, Schedules.ScheduleId from dbo.Bookings join dbo.FlightBookings on dbo.Bookings.BookingId = dbo.FlightBookings.BookingId join dbo.FlightBookingSchedules on dbo.Bookings.BookingId = dbo.FlightBookingSchedules.BookingId join dbo.Schedules on dbo.FlightBookingSchedules.ScheduleId = dbo.Schedules.ScheduleId join dbo.Routes on dbo.Schedules.RouteId = dbo.Routes.RouteId join dbo.Cities f on dbo.Routes.FromCityId = f.CityId join dbo.Cities t on dbo.Routes.ToCityId = t.CityId join dbo.Flights on dbo.Schedules.FlightId = dbo.Flights.FlightId join dbo.Airlines on dbo.Flights.AirlineId = dbo.Airlines.AirlineId ";

                TimeSpan Span = new TimeSpan(23, 59, 59);
                if (BookingsFrom != DateTime.MinValue && BookingsTo != DateTime.MaxValue)
                {
                    strSQL += " and Bookings.BookingDate between '" + BookingsFrom.ToShortDateString() + "' and '" + BookingsTo.Add(Span).ToString() + "'";
                }
                else if (BookingsFrom != DateTime.MinValue)
                {
                    strSQL += " and Bookings.BookingDate >= '" + BookingsFrom.ToShortDateString() + "'";
                }
                else if (BookingsTo != DateTime.MaxValue)
                {
                    strSQL += " and Bookings.BookingDate <= '" + BookingsTo.Add(Span).ToString() + "'";
                }

                using (IDbConnection db = GetConnection())
                {
                    using (IDataReader reader = ExecuteQueryResults(db, strSQL))
                    {
                        lstBookings = new List <FlightBooking>();
                        while (reader.Read())
                        {
                            City FromCity = new City()
                            {
                                CityId = (long)reader["FromCityId"], Name = (string)reader["FromCity"]
                            };
                            City ToCity = new City()
                            {
                                CityId = (long)reader["ToCityId"], Name = (string)reader["ToCity"]
                            };
                            Route RouteInfo = new Route()
                            {
                                ID = (long)reader["RouteId"], IsActive = (bool)reader["Status"], FromCity = FromCity, ToCity = ToCity
                            };

                            Airline AirlineInfo = new Airline()
                            {
                                Id = (int)reader["AirlineId"], Logo = (string)reader["AirlineLogo"], Name = (string)reader["AirlineName"]
                            };
                            Flight FlightInfo = new Flight()
                            {
                                ID = (long)reader["FlightId"], Name = (string)reader["FlightName"], AirlineForFlight = AirlineInfo
                            };

                            Schedule ScheduleInfo = new Schedule()
                            {
                                ID = (long)reader["ScheduleId"], RouteInfo = RouteInfo, FlightInfo = FlightInfo
                            };

                            TravelSchedule TravelScheduleInfo = new TravelSchedule();
                            TravelScheduleInfo.AddSchedule(ScheduleInfo);

                            FlightBooking Booking = new FlightBooking()
                            {
                                BookingId   = (long)reader["BookingId"],
                                BookingDate = (DateTime)reader["BookingDate"],
                                ReferenceNo = (string)reader["BookingReferenceNo"],
                                TotalCost   = (decimal)reader["TotalCost"],
                                IsCanceled  = (bool)reader["IsCanceled"],

                                DateOfJourney = (DateTime)reader["DateOfJourney"],

                                TravelScheduleInfo = TravelScheduleInfo
                            };

                            lstBookings.Add(Booking);
                        }
                    }
                }
            }
            catch (Common.ConnectToDatabaseException ex)
            {
                throw new Exception("Unable to Get Bookings", ex);
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to Get Bookings", ex);
            }

            return(lstBookings);
        }