Exemplo n.º 1
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);
     }
 }
Exemplo n.º 2
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");
        }
Exemplo n.º 3
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);
 }
Exemplo n.º 4
0
        /// <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);
        }