protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { long FromCityId = Convert.ToInt64(Request.QueryString["frmid"].ToString()); long ToCityId = Convert.ToInt64(Request.QueryString["toid"].ToString()); string flightclass = Request.QueryString["clss"].ToString(); int td = Convert.ToInt16(Request.QueryString["td"].ToString()); hdnTravelDirection.Value = td.ToString(); lblHeaderDepart.Text = Convert.ToDateTime(Request.QueryString["depart_date"]).ToString("ddd, dd MMM, yyyy"); lblHeaderReturn.Text = Convert.ToDateTime(Request.QueryString["return_date"]).ToString("ddd, dd MMM, yyyy"); TravelDirection traveldirection = (TravelDirection)td; SearchInfo searchinfo = new SearchInfo(); City fromcity = new City(); searchinfo.OnwardDateOfJourney = Convert.ToDateTime(Request.QueryString["depart_date"]); searchinfo.ReturnDateOfJourney = Convert.ToDateTime(Request.QueryString["return_date"]); fromcity.CityId = FromCityId; City tocity = new City(); tocity.CityId = ToCityId; TravelClass travelclass = (TravelClass)Enum.Parse(typeof(TravelClass), flightclass); searchinfo.FromCity = fromcity; searchinfo.ToCity = tocity; searchinfo.Class = travelclass; searchinfo.Direction = traveldirection; ISearchManager searchmanager = SearchManagerFactory.GetInstance().Create(); SearchLog searchlog = searchmanager.SearchForFlights(searchinfo); SearchResult searchresult = searchlog.GetSearchResult(TravelDirection.OneWay); List <TravelSchedule> lstTravelSchedule = searchresult.GetTravelSchedules(); dlOuterOnward.DataSource = lstTravelSchedule; dlOuterOnward.DataBind(); Session["flightbookingonwardresults"] = lstTravelSchedule; if (lstTravelSchedule.Count > 0) { lblOneWayFromCity.Text = lblHeaderFromCity.Text = lstTravelSchedule[0].GetSchedules()[0].RouteInfo.FromCity.Name; lblOneWayToCity.Text = lblHeaderToCity.Text = lstTravelSchedule[0].GetSchedules()[0].RouteInfo.ToCity.Name; } if (traveldirection == TravelDirection.Return) { SearchResult searchresultreturn = searchlog.GetSearchResult(TravelDirection.Return); List <TravelSchedule> lstTravelScheduleReturn = searchresultreturn.GetTravelSchedules(); dlOuterReturn.DataSource = lstTravelScheduleReturn; dlOuterReturn.DataBind(); Session["flightbookingreturnresults"] = lstTravelScheduleReturn; if (lstTravelScheduleReturn.Count > 0) { lblReturnFromCity.Text = lstTravelScheduleReturn[0].GetSchedules()[0].RouteInfo.FromCity.Name; lblReturnToCity.Text = lstTravelScheduleReturn[0].GetSchedules()[0].RouteInfo.ToCity.Name; } } else { outbound_div.Style.Add("width", "70%"); return_div.Visible = false; lblHeaderReturn.Visible = false; lblHeaderDateSeparator.Visible = false; } } catch { Response.Redirect("~/Error.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { //Get all the information from query string long FromCityId = Convert.ToInt64(Request.QueryString["fromid"].ToString()); long ToCityId = Convert.ToInt64(Request.QueryString["toid"].ToString()); string FromCityName = Request.QueryString["fromCityName"].ToString(); string ToCityName = Request.QueryString["toCityName"].ToString(); string flightclass = Request.QueryString["class"].ToString(); int td = Convert.ToInt16(Request.QueryString["td"].ToString()); string adults = Request.QueryString["adults"].ToString(); //Display the header information lblAdults.Text = adults; hdnTravelDirection.Value = td.ToString(); if (Request.QueryString["depart_date"] != null) { lblHeaderDepart.Text = Convert.ToDateTime(Request.QueryString["depart_date"]).ToString("ddd, dd MMM, yyyy"); } if (Request.QueryString["return_date"] != null) { lblHeaderReturn.Text = Convert.ToDateTime(Request.QueryString["return_date"]).ToString("ddd, dd MMM, yyyy"); } TravelDirection traveldirection = (TravelDirection)td; City fromcity = new City(); fromcity.CityId = FromCityId; fromcity.Name = FromCityName; City tocity = new City(); tocity.CityId = ToCityId; tocity.Name = ToCityName; DateTime onwardDateOfJourney = new DateTime(); if (Request.QueryString["depart_date"] != null) { onwardDateOfJourney = Convert.ToDateTime(Request.QueryString["depart_date"]); } DateTime returnDateOfJourney = new DateTime(); if (Request.QueryString["return_date"] != null) { returnDateOfJourney = Convert.ToDateTime(Request.QueryString["return_date"]); } TravelClass travelclass = (TravelClass)Enum.Parse(typeof(TravelClass), flightclass); //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.01 SearchInfo searchinfo = new SearchInfo(fromcity, tocity, onwardDateOfJourney, returnDateOfJourney, Convert.ToInt32(adults), travelclass, traveldirection); //Contact the search manager and get all the schedules as a search log ISearchManager searchmanager = SearchManagerFactory.GetInstance().Create(); SearchLog searchlog = searchmanager.SearchForFlights(searchinfo); SearchResult searchresult = searchlog.GetSearchResult(TravelDirection.OneWay); List <TravelSchedule> lstTravelSchedule = searchresult.GetTravelSchedules(); dlOuterOnward.DataSource = lstTravelSchedule; dlOuterOnward.DataBind(); Session["flightbookingonwardresults"] = lstTravelSchedule; Session["SearchInfo"] = searchinfo; if (lstTravelSchedule.Count > 0) { lblOneWayFromCity.Text = lblHeaderFromCity.Text = searchinfo.FromCity.Name; lblOneWayToCity.Text = lblHeaderToCity.Text = searchinfo.ToCity.Name; } if (traveldirection == TravelDirection.Return) { SearchResult searchresultreturn = searchlog.GetSearchResult(TravelDirection.Return); List <TravelSchedule> lstTravelScheduleReturn = searchresultreturn.GetTravelSchedules(); dlOuterReturn.DataSource = lstTravelScheduleReturn; dlOuterReturn.DataBind(); Session["flightbookingreturnresults"] = lstTravelScheduleReturn; if (lstTravelScheduleReturn.Count > 0) { lblReturnFromCity.Text = searchinfo.ToCity.Name; lblReturnToCity.Text = searchinfo.FromCity.Name; } } else { outbound_div.Style.Add("width", "70%"); return_div.Visible = false; lblHeaderReturn.Visible = false; lblHeaderDateSeparator.Visible = false; } } catch (Exception ex) { lblError.Visible = true; lblError.Text = ex.Message; } } }