Пример #1
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()).Distinct <Schedule>()
                                                       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.BookingType = BookingTypes.Flight;
                FlightClass ReturnClass = new FlightClass();
                ReturnClass.ClassInfo     = (TravelClass)Enum.Parse(typeof(TravelClass), Request.QueryString["class"]);
                flightbookingreturn.Class = Class;

                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");
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session.Count == 0)
            {
                Response.Redirect("~/Index.aspx");
            }

            if (!IsPostBack)
            {
                decimal TotalCost = 0;
                if (Session["travelbooking"] != null)
                {
                    TravelBooking travelbooking = (TravelBooking)Session["travelbooking"];
                    FlightBooking bookingoneway = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.OneWay);
                    int           NoOfSeats     = bookingoneway.NoOfSeats;

                    List <Passenger> lstPassenger = new List <Passenger>();
                    for (int i = 0; i < NoOfSeats; i++)
                    {
                        lstPassenger.Add(new Passenger {
                            Name = string.Empty, Gender = ' '
                        });
                    }

                    rptrPassengerInfo.DataSource = lstPassenger;
                    rptrPassengerInfo.DataBind();

                    rptrOnwardFlightInfo.DataSource = bookingoneway.TravelScheduleInfo.GetSchedules();
                    rptrOnwardFlightInfo.DataBind();

                    TotalCost = bookingoneway.TotalCost;


                    lblHeaderFromCity.Text = bookingoneway.TravelScheduleInfo.GetSchedules()[0].RouteInfo.FromCity.Name;
                    lblHeaderToCity.Text   = bookingoneway.TravelScheduleInfo.GetSchedules()[0].RouteInfo.ToCity.Name;
                    lblAdults.Text         = bookingoneway.NoOfSeats.ToString();

                    lblHeaderDepart.Text = bookingoneway.DateOfJourney.ToString("ddd, dd MMM, yyyy");

                    lblHeaderDateSeparator.Visible = false;

                    if (Membership.GetUser() != null)
                    {
                        ProfileCommon com = ProfileCommon.GetProfile(Membership.GetUser().UserName.ToString());

                        txtName.Text    = com.Personal.FullName;
                        txtAddress.Text = com.Contact.Address;
                        txtCity.Text    = com.Contact.City;
                        txtState.Text   = com.Contact.State;
                        txtMobile.Text  = com.Contact.MobileNo;
                        txtEmailId.Text = Membership.GetUser().UserName;
                    }

                    bool          isReturnAvailable = travelbooking.IsReturnAvailable();
                    FlightBooking bookingreturn     = null;
                    if (isReturnAvailable)
                    {
                        bookingreturn = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.Return);

                        rptrReturnFlightInfo.DataSource = bookingreturn.TravelScheduleInfo.GetSchedules();
                        rptrReturnFlightInfo.DataBind();

                        divReturn.Visible = true;

                        TotalCost = TotalCost + bookingreturn.TotalCost;

                        lblHeaderReturn.Text = bookingreturn.DateOfJourney.ToString("ddd, dd MMM, yyyy");

                        lblHeaderDateSeparator.Visible = true;
                    }

                    #region Insurance for air travel------------------------
                    if (bookingoneway.Insurance != null)
                    {
                        InsuranceOption.Checked = true;
                    }

                    decimal insuranceValue = 0;
                    //Original Implementation
                    insuranceValue = bookingoneway.TravelScheduleInfo.TotalCostPerTicket * 15 / 100;

                    if (insuranceValue < 250)
                    {
                        insuranceValue = 250;
                    }
                    else if (insuranceValue > 500)
                    {
                        insuranceValue = 500;
                    }
                    lblOnwardInsuranceValue.Text = insuranceValue.ToString();

                    if (isReturnAvailable)
                    {
                        //Original Implementation
                        insuranceValue = bookingreturn.TravelScheduleInfo.TotalCostPerTicket * 15 / 100;
                        //insuranceValue = bookingreturn.TravelScheduleInfo.TotalCostPerTicket;
                        if (insuranceValue < 250)
                        {
                            insuranceValue = 250;
                        }
                        else if (insuranceValue > 500)
                        {
                            insuranceValue = 500;
                        }

                        lblReturnInsuranceValue.Text    = insuranceValue.ToString();
                        lblReturnInsuranceValue.Visible = true;
                        lblINR.Visible = true;
                    }
                    #endregion Insurance for air travel------------------------
                }
                else
                {
                    Response.Redirect("~/Index.aspx");
                }

                lblTotalPrice.Text = TotalCost.ToString();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            #region Obtain the bookingObjects From Session
            if (!IsPostBack)
            {
                decimal       TotalCost           = 0;
                TravelBooking _travelBooking      = null;
                FlightBooking flightbookingonward = null;
                FlightBooking flightbookingreturn = null;
                if (Session["travelBooking"] != null)
                {
                    _travelBooking      = (TravelBooking)Session["travelbooking"];
                    flightbookingonward = (FlightBooking)_travelBooking.GetBookingForTravel(TravelDirection.OneWay);
                    flightbookingreturn = (FlightBooking)_travelBooking.GetBookingForTravel(TravelDirection.Return);
                }
                if (flightbookingonward != null)
                {
                    FlightBooking flightbooking = flightbookingonward;
                    int           NoOfSeats     = flightbooking.NoOfSeats;
                    lblHeaderDepart.Text = flightbooking.DateOfJourney.ToString("ddd, dd MMM, yyyy");
                    lblAdults.Text       = NoOfSeats.ToString();

                    List <Passenger> lstPassenger = flightbooking.GetPassengers();;

                    rptrPassengerInfo.DataSource = lstPassenger;
                    rptrPassengerInfo.DataBind();

                    rptrOnwardFlightInfo.DataSource = flightbooking.TravelScheduleInfo.GetSchedules();
                    rptrOnwardFlightInfo.DataBind();

                    TotalCost = flightbooking.TotalCost;

                    lblHeaderDateSeparator.Visible = false;


                    //Fill Contacts details
                    lblName.Text         = flightbooking.Contact.ContactName;
                    lblAddressline1.Text = flightbooking.Contact.MobileNo;
                    lblState.Text        = flightbooking.Contact.State;
                    lblCity.Text         = flightbooking.Contact.City;
                    lblEmail.Text        = flightbooking.Contact.Email;
                    lblMobno.Text        = flightbooking.Contact.MobileNo;
                    lblPhno.Text         = flightbooking.Contact.PhoneNo;

                    lblHeaderFromCity.Text = flightbooking.TravelScheduleInfo.GetSchedules()[0].RouteInfo.FromCity.Name;
                    lblHeaderToCity.Text   = flightbooking.TravelScheduleInfo.GetSchedules()[0].RouteInfo.ToCity.Name;

                    lblOnwardTicketNo.Text = flightbooking.ReferenceNo;
                }

                if (flightbookingreturn != null)
                {
                    FlightBooking flightbooking = flightbookingreturn;
                    int           NoOfSeats     = flightbooking.NoOfSeats;
                    lblHeaderReturn.Text = flightbooking.DateOfJourney.ToString("ddd, dd MMM, yyyy");

                    rptrReturnFlightInfo.DataSource = flightbooking.TravelScheduleInfo.GetSchedules();
                    rptrReturnFlightInfo.DataBind();

                    divReturn.Visible = true;

                    TotalCost = TotalCost + flightbooking.TotalCost;

                    lblHeaderDateSeparator.Visible = true;

                    pnlReturnTicketNo.Visible = true;
                    lblReturnTicketNo.Text    = flightbooking.ReferenceNo;
                }
            }
            #endregion
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                decimal TotalCost = 0;
                if (Session["travelbooking"] != null)
                {
                    TravelBooking travelbooking = (TravelBooking)Session["travelbooking"];
                    FlightBooking bookingoneway = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.OneWay);
                    int           NoOfSeats     = bookingoneway.NoOfSeats;

                    List <Passenger> lstPassenger = new List <Passenger>();
                    for (int i = 0; i < NoOfSeats; i++)
                    {
                        lstPassenger.Add(new Passenger {
                            Name = string.Empty, Gender = ' '
                        });
                    }

                    rptrPassengerInfo.DataSource = lstPassenger;
                    rptrPassengerInfo.DataBind();

                    rptrOnwardFlightInfo.DataSource = bookingoneway.TravelScheduleInfo.GetSchedules();
                    rptrOnwardFlightInfo.DataBind();

                    TotalCost = bookingoneway.TotalCost;


                    lblHeaderFromCity.Text = ((SearchInfo)Session["SearchInfo"]).FromCity.Name;
                    lblHeaderToCity.Text   = ((SearchInfo)Session["SearchInfo"]).ToCity.Name;
                    lblAdults.Text         = bookingoneway.NoOfSeats.ToString() + " Seats";

                    lblHeaderDepart.Text = bookingoneway.DateOfJourney.ToString("ddd, dd MMM, yyyy");

                    lblHeaderDateSeparator.Visible = false;

                    if (Membership.GetUser() != null)
                    {
                        ProfileCommon com = ProfileCommon.GetProfile(Membership.GetUser().UserName.ToString());

                        txtName.Text    = com.Personal.FullName;
                        txtAddress.Text = com.Contact.Address;
                        txtCity.Text    = com.Contact.City;
                        txtState.Text   = com.Contact.State;
                        txtMobile.Text  = com.Contact.MobileNo;
                        txtEmailId.Text = com.Contact.Email;
                    }

                    if (travelbooking.IsReturnAvailable())
                    {
                        FlightBooking bookingreturn = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.Return);

                        rptrReturnFlightInfo.DataSource = bookingreturn.TravelScheduleInfo.GetSchedules();
                        rptrReturnFlightInfo.DataBind();

                        divReturn.Visible = true;

                        TotalCost = TotalCost + bookingreturn.TotalCost;

                        lblHeaderReturn.Text = bookingreturn.DateOfJourney.ToString("ddd, dd MMM, yyyy");

                        lblHeaderDateSeparator.Visible = true;
                    }
                }

                lblTotalPrice.Text = TotalCost.ToString();
            }
        }
Пример #5
0
        protected void btnBook_Click(object sender, EventArgs e)
        {
            try
            {
                if (Session["travelbooking"] != null)
                {
                    TravelBooking travelbooking = (TravelBooking)Session["travelbooking"];

                    FlightBooking travelbookingoneway = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.OneWay);
                    travelbookingoneway.GetPassengers().Clear();

                    FlightBooking travelbookingReturn = null;
                    bool          isReturnAvailable   = false;
                    if (travelbooking.IsReturnAvailable())
                    {
                        isReturnAvailable   = true;
                        travelbookingReturn = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.Return);
                        travelbookingReturn.GetPassengers().Clear();
                    }

                    foreach (RepeaterItem item in rptrPassengerInfo.Items)
                    {
                        TextBox      Name   = (TextBox)item.FindControl("AdultFname");
                        DropDownList Gender = (DropDownList)item.FindControl("ddlGender");
                        TextBox      DOB    = (TextBox)item.FindControl("txtDOB");

                        DateTime dtDOB;
                        if (DateTime.TryParse(DOB.Text, out dtDOB) == false)
                        {
                            lblError.Text = "Invalid Date of Birth";
                            return;
                        }
                        else
                        {
                            if (dtDOB > DateTime.Now)
                            {
                                lblError.Text = "Birthday is in the future.";
                                return;
                            }
                            lblError.Text = "";
                        }

                        travelbookingoneway.AddPassenger(new Passenger {
                            Name = Name.Text, DateOfBirth = dtDOB, Gender = Gender.SelectedItem.Value.ToCharArray()[0]
                        });
                        if (isReturnAvailable)
                        {
                            travelbookingReturn.AddPassenger(new Passenger {
                                Name = Name.Text, DateOfBirth = dtDOB, Gender = Gender.SelectedItem.Value.ToCharArray()[0]
                            });
                        }
                    }

                    //Insurance captured if user has selected insurance
                    if (InsuranceOption.Checked)
                    {
                        FlightBooking   bookingoneway = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.OneWay);
                        TravelInsurance insurance     = new TravelInsurance();
                        insurance.Amount = Convert.ToDecimal(lblOnwardInsuranceValue.Text) * bookingoneway.NoOfSeats;
                        travelbookingoneway.Insurance = insurance;

                        if (isReturnAvailable)
                        {
                            FlightBooking   bookingReturh   = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.Return);
                            TravelInsurance insuranceReturn = new TravelInsurance();
                            insuranceReturn.Amount        = Convert.ToDecimal(lblReturnInsuranceValue.Text) * bookingReturh.NoOfSeats;
                            travelbookingReturn.Insurance = insuranceReturn;
                        }
                    }
                    //-------------------------------------------------

                    BookingContact bookingcontact = new BookingContact();
                    bookingcontact.Address     = txtAddress.Text;
                    bookingcontact.City        = txtCity.Text;
                    bookingcontact.ContactName = txtName.Text;
                    bookingcontact.Email       = txtEmailId.Text;
                    bookingcontact.MobileNo    = txtMobile.Text;
                    bookingcontact.PhoneNo     = txtPhoneNumber.Text;
                    bookingcontact.State       = txtState.Text;

                    travelbookingoneway.Contact = bookingcontact;
                    travelbooking.AddBookingForTravel(TravelDirection.OneWay, travelbookingoneway);

                    if (isReturnAvailable)
                    {
                        travelbookingReturn.Contact = bookingcontact;
                        travelbooking.AddBookingForTravel(TravelDirection.Return, travelbookingReturn);
                    }


                    Session["travelbooking"] = travelbooking;
                }

                Response.Redirect("~/booking/confirmation.aspx");
            }
            catch (Exception)
            {
                lblError.Text = "Please check the information entered";
            }
        }
Пример #6
0
        /// <summary>
        /// Processes a booking to be made - flight
        /// </summary>
        /// <param name="newTravelBooking"></param>
        /// <param name="cardForBooking"></param>
        /// <returns>Returns a travel booking object updated with all the booking information</returns>
        public TravelBooking ProcessAirTravelBooking(TravelBooking newTravelBooking, Card cardForBooking)
        {
            bool   isAvailable        = false;
            string bookingReferenceNo = string.Empty;

            PaymentStatus status;
            string        paymentReferenceNumber = string.Empty;

            //Checking for Availability of Schedules before porcessing the booking
            //1. Check for Availablity
            try
            {
                isAvailable = CheckAvailabilityForBooking(newTravelBooking);
            }
            catch (Search.FlightSeatsAvailabilityException Ex)
            {
                throw Ex;
            }
            catch (Exception ex)
            {
                throw new Search.FlightSeatsAvailabilityException("Seats Not Available", ex);
            }

            //If available, then make payment and store in database using transactions
            //If Available then do rest of the code
            if (isAvailable)
            {
                TransactionOptions options = new TransactionOptions();
                options.IsolationLevel = IsolationLevel.ReadCommitted;
                options.Timeout        = TransactionManager.MaximumTimeout;

                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
                {
                    try
                    {
                        //Processing the payment
                        paymentReferenceNumber = ProcessAirTravelBookingPayment(newTravelBooking, cardForBooking, out status);

                        //Store in database
                        if (PaymentStatus.Success == status)
                        {
                            //Persist in the database
                            foreach (TravelDirection Direction in newTravelBooking.GetBookingTravelDirections())
                            {
                                bookingReferenceNo = StoreBookingInDatabase(newTravelBooking.GetBookingForTravel(Direction));
                                newTravelBooking.GetBookingForTravel(Direction).ReferenceNo = bookingReferenceNo;
                            }

                            scope.Complete();
                        }
                    }
                    catch (PaymentProcessException ex)
                    {
                        scope.Dispose();
                        throw ex;
                    }
                    catch (InvalidBookingTypeException ex)
                    {
                        scope.Dispose();
                        throw ex;
                    }
                    catch (StoreBookingInDatabaseException ex)
                    {
                        scope.Dispose();
                        throw new BookingException("Unable to Book Tickets", ex);
                    }
                    catch (Exception ex)
                    {
                        scope.Dispose();
                        throw new BookingException("Unable to Book Tickets", ex);
                    }
                }
            }

            return(newTravelBooking);
        }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            #region Obtain the bookingObjects From Session
            if (!IsPostBack)
            {
                decimal       TotalCost           = 0;
                TravelBooking _travelBooking      = null;
                FlightBooking flightbookingonward = null;
                FlightBooking flightbookingreturn = null;
                if (Session["travelBooking"] != null)
                {
                    _travelBooking      = (TravelBooking)Session["travelbooking"];
                    flightbookingonward = (FlightBooking)_travelBooking.GetBookingForTravel(TravelDirection.OneWay);
                    flightbookingreturn = (FlightBooking)_travelBooking.GetBookingForTravel(TravelDirection.Return);
                }
                else
                {
                    Response.Redirect("~/Index.aspx");
                }
                if (flightbookingonward != null)
                {
                    FlightBooking flightbooking = flightbookingonward;
                    int           NoOfSeats     = flightbooking.NoOfSeats;
                    lblHeaderDepart.Text = flightbooking.DateOfJourney.ToString("ddd, dd MMM, yyyy");
                    lblAdults.Text       = NoOfSeats.ToString();

                    List <Passenger> lstPassenger = flightbooking.GetPassengers();;

                    rptrPassengerInfo.DataSource = lstPassenger;
                    rptrPassengerInfo.DataBind();

                    rptrOnwardFlightInfo.DataSource = flightbooking.TravelScheduleInfo.GetSchedules();
                    rptrOnwardFlightInfo.DataBind();

                    TotalCost = flightbooking.TotalCost;

                    lblHeaderDateSeparator.Visible = false;


                    //Fill Contacts details
                    lblName.Text         = flightbooking.Contact.ContactName;
                    lblAddressline1.Text = flightbooking.Contact.MobileNo;
                    lblState.Text        = flightbooking.Contact.State;
                    lblCity.Text         = flightbooking.Contact.City;
                    lblEmail.Text        = flightbooking.Contact.Email;
                    lblMobno.Text        = flightbooking.Contact.MobileNo;
                    lblPhno.Text         = flightbooking.Contact.PhoneNo;

                    lblHeaderFromCity.Text = flightbooking.TravelScheduleInfo.GetSchedules()[0].RouteInfo.FromCity.Name;
                    lblHeaderToCity.Text   = flightbooking.TravelScheduleInfo.GetSchedules()[0].RouteInfo.ToCity.Name;

                    lblOnwardTicketNo.Text = flightbooking.ReferenceNo;
                }

                if (flightbookingreturn != null)
                {
                    FlightBooking flightbooking = flightbookingreturn;
                    int           NoOfSeats     = flightbooking.NoOfSeats;
                    lblHeaderReturn.Text = flightbooking.DateOfJourney.ToString("ddd, dd MMM, yyyy");

                    rptrReturnFlightInfo.DataSource = flightbooking.TravelScheduleInfo.GetSchedules();
                    rptrReturnFlightInfo.DataBind();

                    divReturn.Visible = true;

                    TotalCost = TotalCost + flightbooking.TotalCost;

                    lblHeaderDateSeparator.Visible = true;

                    pnlReturnTicketNo.Visible = true;
                    lblReturnTicketNo.Text    = flightbooking.ReferenceNo;
                }

                //Insurance Display
                decimal insuranceOnwardAmount = 0;
                decimal insuranceReturnAmount = 0;
                if (flightbookingonward.Insurance != null)
                {
                    insuranceOnwardAmount = flightbookingonward.Insurance.Amount;

                    if (flightbookingreturn != null && flightbookingreturn.Insurance != null)
                    {
                        insuranceReturnAmount = flightbookingreturn.Insurance.Amount;
                    }

                    lblInsuranceText.Text  = "You have opted to go for travel insurance for the amount : ";
                    lblInsuranceValue.Text = "Onward Journey : INR " + (insuranceOnwardAmount / flightbookingonward.NoOfSeats) + " /- Per Passenger ";

                    if (insuranceReturnAmount > 0)
                    {
                        lblInsuranceValue.Text += "-- Return Journey : INR " + (insuranceReturnAmount / flightbookingreturn.NoOfSeats) + " /- Per Passenger ";
                    }

                    lblInsuranceText.Visible  = true;
                    lblInsuranceValue.Visible = true;
                }
                else
                {
                    lblInsuranceValue.Text    = "INR 0.0";
                    lblInsuranceValue.Visible = true;
                }

                lblTotalPrice.Text = "INR " + (TotalCost - (insuranceOnwardAmount + insuranceReturnAmount)).ToString();

                lblGrandTotal.Text = "INR " + TotalCost.ToString();


                if (Session["happymiles"] != null)
                {
                    int happyMiles = (int)Session["happymiles"];
                    lblHappyMiles.Text = "Happy miles earned in this transaction is " + happyMiles.ToString();
                }
            }
            //Clean up the session
            Session.Clear();

            #endregion
        }
        protected void btnBook_Click(object sender, EventArgs e)
        {
            int            happyMiles = 0;
            MembershipUser mUser      = Membership.GetUser();
            decimal        travelCost = 0;
            string         userName   = "";

            try
            {
                int CardExpiryYear  = Convert.ToInt16(ddlccExpirationYear.SelectedItem.Value);
                int CardExpiryMonth = Convert.ToInt16(ddlccExpirationMonth.SelectedItem.Value);
                int cardType        = Convert.ToInt16(ddlccCardType.SelectedItem.Value);

                if (ValidatePaymentDetails(CardExpiryMonth, CardExpiryYear))
                {
                    TravelBooking travelbooking = (TravelBooking)Session["travelbooking"];
                    Card          _card         = new Card()
                    {
                        CardNo = txtCard_no.Text, Cvv2No = txtCvv.Text, Name = txtcard_holder.Text, ExpiryYear = CardExpiryYear, ExpiryMonth = CardExpiryMonth, CardType = (CardTypes)cardType
                    };

                    IBookingManager _bookingManager     = BookingManagerFactory.GetInstance().Create();
                    TravelBooking   travelbookingresult = null;

                    travelbookingresult = _bookingManager.ProcessAirTravelBooking(travelbooking, _card);

                    if (Request.IsAuthenticated)
                    {
                        //Added by Anand for updated travel miles
                        IHappyMiles travelMiles = new HappyMilesManager();

                        List <int> theAirlines = new List <int>();

                        //AirlineIDs for the onwared flights
                        FlightBooking flightBookingOnward = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.OneWay);
                        if (flightBookingOnward != null)
                        {
                            theAirlines.Clear();
                            List <Schedule> theSchedules = flightBookingOnward.TravelScheduleInfo.GetSchedules();
                            if (theSchedules != null)
                            {
                                foreach (Schedule schedule in theSchedules)
                                {
                                    theAirlines.Add(schedule.FlightInfo.AirlineForFlight.Id);
                                }
                                if (mUser != null)
                                {
                                    userName = mUser.UserName;
                                    decimal insurance = 0;
                                    if (flightBookingOnward.Insurance != null)
                                    {
                                        insurance = flightBookingOnward.Insurance.Amount;
                                    }
                                    travelCost  = travelbooking.GetBookingForTravel(TravelDirection.OneWay).TotalCost - insurance;
                                    happyMiles += travelMiles.UpdateHappyMilesForUser(userName, theAirlines, (double)travelCost, flightBookingOnward.ReferenceNo);
                                }
                            }
                        }

                        if (travelbooking.IsReturnAvailable())
                        {
                            //AirlineIDs for the return flights
                            theAirlines.Clear();
                            FlightBooking   flightBookingReturn = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.Return);
                            List <Schedule> theSchedules        = flightBookingReturn.TravelScheduleInfo.GetSchedules();
                            if (theSchedules != null)
                            {
                                foreach (Schedule schedule in theSchedules)
                                {
                                    theAirlines.Add(schedule.FlightInfo.AirlineForFlight.Id);
                                }
                                if (mUser != null)
                                {
                                    userName = mUser.UserName;
                                    decimal insurance = 0;
                                    if (flightBookingOnward.Insurance != null)
                                    {
                                        insurance = flightBookingOnward.Insurance.Amount;
                                    }
                                    travelCost  = travelbooking.GetBookingForTravel(TravelDirection.Return).TotalCost - insurance;
                                    happyMiles += travelMiles.UpdateHappyMilesForUser(userName, theAirlines, (double)travelCost, flightBookingReturn.ReferenceNo);
                                }
                            }
                        }

                        ((SiteMaster)Master).ShowHappyMilesForUser();
                        Session["happymiles"] = happyMiles;
                    }

                    Session["travelbooking"] = travelbookingresult;

                    Response.Redirect("~/booking/Payment_Success.aspx");
                }
            }
            catch (HappyTrip.Model.BusinessLayer.Search.FlightSeatsAvailabilityException ex)
            {
                lblUnSuccessful.Visible = true;
                lblUnSuccessful.Text    = ex.Message;
            }
            catch (PaymentProcessException ex)
            {
                lblUnSuccessful.Visible = true;
                lblUnSuccessful.Text    = ex.Message;
            }
            catch (InvalidBookingTypeException ex)
            {
                lblUnSuccessful.Visible = true;
                lblUnSuccessful.Text    = ex.Message;
            }
            catch (BookingException ex)
            {
                lblUnSuccessful.Visible = true;
                lblUnSuccessful.Text    = ex.Message;
            }
            catch (Exception)
            {
                lblUnSuccessful.Visible = true;
                lblUnSuccessful.Text    = "Unable to Book Tickets";
            }
        }
Пример #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session.Count == 0)
            {
                Response.Redirect("~/Index.aspx");
            }
            if (!IsPostBack)
            {
                try
                {
                    #region Obtain the bookingObjects From Session
                    decimal       totalCost           = 0;
                    TravelBooking _travelBooking      = null;
                    FlightBooking flightbookingonward = null;
                    FlightBooking flightbookingreturn = null;
                    if (Session["travelbooking"] != null)
                    {
                        _travelBooking      = (TravelBooking)Session["travelbooking"];
                        flightbookingonward = (FlightBooking)_travelBooking.GetBookingForTravel(TravelDirection.OneWay);
                        flightbookingreturn = (FlightBooking)_travelBooking.GetBookingForTravel(TravelDirection.Return);
                    }
                    else
                    {
                        Response.Redirect("~/Index.aspx");
                    }
                    if (flightbookingonward != null)
                    {
                        int NoOfSeats = flightbookingonward.NoOfSeats;

                        List <Passenger> lstPassenger = flightbookingonward.GetPassengers();;

                        rptrPassengerInfo.DataSource = lstPassenger;
                        rptrPassengerInfo.DataBind();

                        rptrOnwardFlightInfo.DataSource = flightbookingonward.TravelScheduleInfo.GetSchedules();
                        rptrOnwardFlightInfo.DataBind();

                        totalCost = flightbookingonward.TotalCost;

                        lblHeaderFromCity.Text = flightbookingonward.TravelScheduleInfo.GetSchedules()[0].RouteInfo.FromCity.Name;
                        lblHeaderToCity.Text   = flightbookingonward.TravelScheduleInfo.GetSchedules()[0].RouteInfo.ToCity.Name;
                        lblAdults.Text         = flightbookingonward.NoOfSeats.ToString();

                        lblHeaderDepart.Text = flightbookingonward.DateOfJourney.ToString("ddd, dd MMM, yyyy");

                        lblHeaderDateSeparator.Visible = false;
                        if (_travelBooking.IsReturnAvailable())
                        {
                            lblHeaderDateSeparator.Visible = true;
                        }

                        //Fill Contacts details
                        lblName.Text         = flightbookingonward.Contact.ContactName;
                        lblAddressline1.Text = flightbookingonward.Contact.MobileNo;
                        lblState.Text        = flightbookingonward.Contact.State;
                        lblCity.Text         = flightbookingonward.Contact.City;
                        lblEmail.Text        = flightbookingonward.Contact.Email;
                        lblMobno.Text        = flightbookingonward.Contact.MobileNo;
                        lblPhno.Text         = flightbookingonward.Contact.PhoneNo;
                    }

                    if (flightbookingreturn != null)
                    {
                        int NoOfSeats = flightbookingreturn.NoOfSeats;

                        rptrReturnFlightInfo.DataSource = flightbookingreturn.TravelScheduleInfo.GetSchedules();
                        rptrReturnFlightInfo.DataBind();

                        divReturn.Visible = true;

                        totalCost = totalCost + flightbookingreturn.TotalCost;

                        lblHeaderReturn.Text = flightbookingreturn.DateOfJourney.ToString("ddd, dd MMM, yyyy");
                    }

                    //Insurance Display
                    decimal insuranceOnwardAmount = 0;
                    decimal insuranceReturnAmount = 0;
                    if (flightbookingonward.Insurance != null)
                    {
                        insuranceOnwardAmount = flightbookingonward.Insurance.Amount;

                        if (flightbookingreturn != null && flightbookingreturn.Insurance != null)
                        {
                            insuranceReturnAmount = flightbookingreturn.Insurance.Amount;
                        }

                        lblInsuranceText.Text  = "You have opted to go for travel insurance for the amount : ";
                        lblInsuranceValue.Text = "Onward Journey : INR " + (insuranceOnwardAmount / flightbookingonward.NoOfSeats) + " /- Per Passenger ";

                        if (insuranceReturnAmount > 0)
                        {
                            lblInsuranceValue.Text += "-- Return Journey : INR " + (insuranceReturnAmount / flightbookingreturn.NoOfSeats) + " /- Per Passenger ";
                        }

                        lblInsuranceText.Visible  = true;
                        lblInsuranceValue.Visible = true;
                    }
                    else
                    {
                        lblInsuranceValue.Text    = "INR 0.0";
                        lblInsuranceValue.Visible = true;
                    }

                    lblTotalPrice.Text = "INR " + totalCost.ToString();

                    lblGrandTotal.Text = "INR " + (totalCost + insuranceOnwardAmount + insuranceReturnAmount).ToString();

                    #endregion
                }
                catch (Exception)
                {
                    lblHeaderDepart.Text = "Sorry !!! Unable to display details";
                }
            }
        }
Пример #10
0
        /// <summary>
        /// Process Air Travel Booking payment
        /// </summary>
        /// <param name="newTravelBooking"></param>
        /// <param name="cardForBooking"></param>
        /// <param name="status"></param>
        /// <returns>Returns payment reference number</returns>
        private string ProcessAirTravelBookingPayment(TravelBooking newTravelBooking, Card cardForBooking, out PaymentStatus status)
        {
            string  paymentReferenceNumber = string.Empty;
            decimal travelTotalCost        = 0;

            //Calculating the cost
            travelTotalCost = newTravelBooking.GetBookingForTravel(TravelDirection.OneWay).TotalCost;

            if (newTravelBooking.IsReturnAvailable())
            {
                travelTotalCost += newTravelBooking.GetBookingForTravel(TravelDirection.Return).TotalCost;
            }

            FlightBooking bookingOnward = (FlightBooking)(newTravelBooking.GetBookingForTravel(TravelDirection.OneWay));

            if (bookingOnward.Insurance != null)
            {
                decimal travelInsuranceOnward = (bookingOnward.Insurance.Amount);
                travelTotalCost += travelInsuranceOnward;
                newTravelBooking.GetBookingForTravel(TravelDirection.OneWay).TotalCost += travelInsuranceOnward;
            }

            FlightBooking bookingReturn = (FlightBooking)(newTravelBooking.GetBookingForTravel(TravelDirection.Return));

            if (bookingReturn != null && bookingReturn.Insurance != null)
            {
                decimal travelInsuranceReturn = (bookingReturn.Insurance.Amount);
                travelTotalCost += travelInsuranceReturn;
                newTravelBooking.GetBookingForTravel(TravelDirection.Return).TotalCost += travelInsuranceReturn;
            }
            //Make a Payment and update the booking reference number into booking object
            try
            {
                paymentReferenceNumber = MakePayment(cardForBooking, travelTotalCost, out status);

                if (status == PaymentStatus.Success)
                {
                    foreach (TravelDirection direction in newTravelBooking.GetBookingTravelDirections())
                    {
                        Payment newPayment = new Payment();
                        newPayment.Amount      = travelTotalCost;
                        newPayment.PaymentDate = DateTime.Now;
                        newPayment.ReferenceNo = paymentReferenceNumber;

                        newTravelBooking.GetBookingForTravel(direction).PaymentInfo = newPayment;
                    }
                }
                else
                {
                    throw new PaymentProcessException("Unable to Process Payment");
                }
            }
            catch (PaymentProcessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                throw new PaymentProcessException("Unable to Process Payment", ex);
            }

            return(paymentReferenceNumber);
        }