protected void Page_Load(object sender, EventArgs e) { if (Session.Count == 0) { Response.Redirect("~/Index.aspx"); } if (Session["travelbooking"] != null) { lblHeaderDateSeparator.Visible = false; TravelBooking travelbooking = (TravelBooking)Session["travelbooking"]; FlightBooking bookingoneway = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.OneWay); 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"); if (travelbooking.IsReturnAvailable()) { lblHeaderDateSeparator.Visible = true; FlightBooking bookingreturn = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.Return); lblHeaderReturn.Text = bookingreturn.DateOfJourney.ToString("ddd, dd MMM, yyyy"); } } else { Response.Redirect("~/Index.aspx"); } }
/// <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; } //Make a Payment and update the booking reference number into booking object try { bool isCardValid = ValidateCardInfo(cardForBooking); if (isCardValid) { paymentReferenceNumber = MakePayment(cardForBooking, travelTotalCost, out status); if (PaymentStatus.Success == status) { foreach (TravelDirection direction in newTravelBooking.GetBookingTravelDirections()) { //Calling the Parameterized Constructor //This is done once the class variables are set to private set //and a paramterized constructor is introduced //Using VS - Effectively - CR - STYCBG09.04 Payment newPayment = new Payment(DateTime.Now, travelTotalCost, paymentReferenceNumber); newTravelBooking.GetBookingForTravel(direction).PaymentInfo = newPayment; } } else { throw new PaymentProcessException("Unable to Process Payment"); } } else { throw new PaymentProcessException("Unable to Process Payment"); } } catch (PaymentProcessException ex) { throw; } catch (Exception ex) { throw new PaymentProcessException("Unable to Process Payment", ex); } return(paymentReferenceNumber); }
/// <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; } //Make a Payment and update the booking reference number into booking object try { bool isCardValid = ValidateCardInfo(cardForBooking); if (isCardValid) { paymentReferenceNumber = MakePayment(cardForBooking, travelTotalCost, out status); if (PaymentStatus.Success == status) { 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"); } } else { throw new PaymentProcessException("Unable to Process Payment"); } } catch (PaymentProcessException) { throw; } catch (Exception ex) { throw new PaymentProcessException("Unable to Process Payment", ex); } return(paymentReferenceNumber); }
protected void btnBook_Click(object sender, EventArgs e) { if (Session["travelbooking"] != null) { TravelBooking travelbooking = (TravelBooking)Session["travelbooking"]; FlightBooking travelbookingoneway = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.OneWay); foreach (RepeaterItem item in rptrPassengerInfo.Items) { TextBox Name = (TextBox)item.FindControl("AdultFname"); DropDownList Gender = (DropDownList)item.FindControl("ddlGender"); TextBox DOB = (TextBox)item.FindControl("txtDOB"); //Calling the Parameterized Constructor //This is done once the class variables are set to private set //and a paramterized constructor is introduced //Using VS - Effectively - CR - STYCBG09.02 Passenger passenger = new Passenger(Name.Text, Gender.SelectedItem.Value.ToCharArray()[0], Convert.ToDateTime(DOB.Text)); travelbookingoneway.AddPassenger(passenger); } 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 (travelbooking.IsReturnAvailable()) { FlightBooking TravelBookingReturn = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.Return); foreach (var passenger in travelbookingoneway.GetPassengers()) { TravelBookingReturn.AddPassenger(passenger); } TravelBookingReturn.Contact = bookingcontact; travelbooking.AddBookingForTravel(TravelDirection.Return, TravelBookingReturn); } Session["travelbooking"] = travelbooking; } Response.Redirect("~/booking/confirmation.aspx"); }
protected void btnBook_Click(object sender, EventArgs e) { if (Session["travelbooking"] != null) { TravelBooking travelbooking = (TravelBooking)Session["travelbooking"]; FlightBooking travelbookingoneway = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.OneWay); foreach (RepeaterItem item in rptrPassengerInfo.Items) { TextBox Name = (TextBox)item.FindControl("AdultFname"); DropDownList Gender = (DropDownList)item.FindControl("ddlGender"); TextBox DOB = (TextBox)item.FindControl("txtDOB"); Passenger passenger = new Passenger { Name = Name.Text, DateOfBirth = Convert.ToDateTime(DOB.Text), Gender = Gender.SelectedItem.Value.ToCharArray()[0] }; travelbookingoneway.AddPassenger(passenger); } 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 (travelbooking.IsReturnAvailable()) { FlightBooking TravelBookingReturn = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.Return); foreach (var passenger in travelbookingoneway.GetPassengers()) { TravelBookingReturn.AddPassenger(passenger); } TravelBookingReturn.Contact = bookingcontact; travelbooking.AddBookingForTravel(TravelDirection.Return, TravelBookingReturn); } Session["travelbooking"] = travelbooking; } Response.Redirect("~/booking/confirmation.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if (Session["travelbooking"] != null) { lblHeaderDateSeparator.Visible = false; TravelBooking travelbooking = (TravelBooking)Session["travelbooking"]; FlightBooking bookingoneway = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.OneWay); 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"); if (travelbooking.IsReturnAvailable()) { lblHeaderDateSeparator.Visible = true; FlightBooking bookingreturn = (FlightBooking)travelbooking.GetBookingForTravel(TravelDirection.Return); lblHeaderReturn.Text = bookingreturn.DateOfJourney.ToString("ddd, dd MMM, yyyy"); } } }
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++) { //Calling the Default Constructor //This is done once the class variables are set to private set //Using VS - Effectively - CR - STYCBG09.02 lstPassenger.Add(new Passenger()); } 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(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { #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; List <Passenger> lstPassenger = flightbooking.GetPassengers();; rptrPassengerInfo.DataSource = lstPassenger; rptrPassengerInfo.DataBind(); rptrOnwardFlightInfo.DataSource = flightbooking.TravelScheduleInfo.GetSchedules(); rptrOnwardFlightInfo.DataBind(); TotalCost = flightbooking.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 = 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; } if (flightbookingreturn != null) { FlightBooking flightbooking = flightbookingreturn; int NoOfSeats = flightbooking.NoOfSeats; rptrReturnFlightInfo.DataSource = flightbooking.TravelScheduleInfo.GetSchedules(); rptrReturnFlightInfo.DataBind(); divReturn.Visible = true; TotalCost = TotalCost + flightbooking.TotalCost; lblHeaderReturn.Text = flightbookingreturn.DateOfJourney.ToString("ddd, dd MMM, yyyy"); } lblTotalPrice.Text = TotalCost.ToString(); } #endregion } }
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 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"; } }
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"; } }
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"; } } }
/// <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); }