public void ShowHappyMilesForUser() { if (Request.IsAuthenticated) { lblMiles.Text = "Miles to redeem: "; try { MembershipUser mUser = Membership.GetUser(); string userName = mUser.UserName; HappyMilesManager tmm = new HappyMilesManager(); int tm = tmm.GetHappyMilesForUser(userName); lblMiles.Text += tm.ToString(); } catch (Exception) { lblMiles.Text += "Error!"; } } }
private int GetHappyMiles(string refno) { IHappyMiles happyMilesMgr = new HappyMilesManager(); return(happyMilesMgr.GetHappyMilesForBookingReference(refno)); }
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"; } }