Exemplo n.º 1
0
        public ActionResult GetCars(FormCollection collection)
        {
            sessionPick = collection["pickUpLocation"].Substring(0, 3);
            sessionDrop = collection["dropLocation"].Substring(0, 3);
            string sessionName   = "SearchResult" + sessionPick + sessionDrop + collection["pickUpDate"];
            var    searchCarInfo = new SearchCarInfo[] { };

            if (Session[sessionName] == null)
            {
                SearchCarsRequest request = new SearchCarsRequest();
                Route             route   = new Route();
                route.PickUp  = collection["pickUpLocation"].Substring(0, 3);
                route.DropOff = collection["dropLocation"].Substring(0, 3);
                //request.Route.PickUp = "MCO";
                //request.Route.DropOff = "MCO";
                request.Route       = route;
                request.PickUpDate  = Convert.ToDateTime(collection["pickUpDate"]);
                request.DropOffDate = Convert.ToDateTime(collection["dropDate"]);
                request.PickUpHour  = Convert.ToInt32(collection["ddlPickUpHour"]);
                request.DropOffHour = Convert.ToInt32(collection["ddlDropHour"]);
                request.VehicleType = Convert.ToInt32(collection["ddlVehicleType"]);
                request.CarCompany  = Convert.ToInt32(collection["ddlCarCompany"]);
                request.TotalPax    = Convert.ToInt32(collection["ddlTotalPax"]);


                var resultsInfo = new ResultsInfo();

                CarServiceClient carSvc = new CarServiceClient();
                var result =
                    carSvc.SearchCarsByAirportCode(
                        new LoginHeader {
                    UserName = "******", Password = "******", Culture = "en-US", Version = "1"
                },
                        request, out searchCarInfo, out resultsInfo);

                Session[sessionName] = searchCarInfo;
            }
            else
            {
                searchCarInfo = (SearchCarInfo[])Session[sessionName];
            }
            ViewBag.SessionId = sessionName;
            return(View(searchCarInfo));
        }
Exemplo n.º 2
0
        public ActionResult GetCars(FormCollection collection)
        {
            //Based on lat and long get the airport code
            string url        = string.Format("http://iatageo.com/getCode/{0}/{1}", collection["lati"], collection["long"]);
            var    getRequest = WebRequest.Create(url);

            getRequest.ContentType = "application/json; charset=utf-8";
            string text;
            var    response = (HttpWebResponse)getRequest.GetResponse();

            // ReSharper disable once AssignNullToNotNullAttribute
            using (var sr = new StreamReader(response.GetResponseStream()))
            {
                text = sr.ReadToEnd();
            }

            dynamic jsonResp = JsonConvert.DeserializeObject(text);

            //Assumption for test - pick and drop location same.
            sessionPick = jsonResp["IATA"];
            sessionDrop = jsonResp["IATA"];
            string sessionName   = "SearchResult" + sessionPick + sessionDrop + collection["pickUpDate"];
            var    searchCarInfo = new SearchCarInfo[] { };

            if (Session[sessionName] == null)
            {
                SearchCarsRequest request = new SearchCarsRequest();
                Route             route   = new Route();
                route.PickUp  = sessionPick;
                route.DropOff = sessionPick;
                //request.Route.PickUp = "MCO";
                //request.Route.DropOff = "MCO";
                request.Route       = route;
                request.PickUpDate  = Convert.ToDateTime(collection["pickUpDate"]);
                request.DropOffDate = Convert.ToDateTime(collection["dropDate"]);
                request.PickUpHour  = Convert.ToInt32(collection["ddlPickUpHour"]);
                request.DropOffHour = Convert.ToInt32(collection["ddlDropHour"]);
                request.VehicleType = Convert.ToInt32(collection["ddlVehicleType"]);
                request.CarCompany  = Convert.ToInt32(collection["ddlCarCompany"]);
                request.TotalPax    = Convert.ToInt32(collection["ddlTotalPax"]);


                var resultsInfo = new ResultsInfo();

                CarServiceClient carSvc = new CarServiceClient();
                var result =
                    carSvc.SearchCarsByAirportCode(
                        new LoginHeader {
                    UserName = "******", Password = "******", Culture = "en-US", Version = "1"
                },
                        request, out searchCarInfo, out resultsInfo);

                Session[sessionName] = searchCarInfo;
            }
            else
            {
                searchCarInfo = (SearchCarInfo[])Session[sessionName];
            }
            ViewBag.SessionId = sessionName;
            return(View(searchCarInfo));
        }
Exemplo n.º 3
0
        public ActionResult GetCars(FormCollection collection)
        {
            sessionPick = collection["pickUpLocation"].Substring(0, 3);
            sessionDrop = collection["dropLocation"].Substring(0, 3);
            string sessionName = "SearchResult" + sessionPick + sessionDrop + collection["pickUpDate"];
            var searchCarInfo = new SearchCarInfo[] { };
            if (Session[sessionName] == null)
            {
                SearchCarsRequest request = new SearchCarsRequest();
                Route route = new Route();
                route.PickUp = collection["pickUpLocation"].Substring(0, 3);
                route.DropOff = collection["dropLocation"].Substring(0, 3);
                //request.Route.PickUp = "MCO";
                //request.Route.DropOff = "MCO";
                request.Route = route;
                request.PickUpDate = Convert.ToDateTime(collection["pickUpDate"]);
                request.DropOffDate = Convert.ToDateTime(collection["dropDate"]);
                request.PickUpHour = Convert.ToInt32(collection["ddlPickUpHour"]);
                request.DropOffHour = Convert.ToInt32(collection["ddlDropHour"]);
                request.VehicleType = Convert.ToInt32(collection["ddlVehicleType"]);
                request.CarCompany = Convert.ToInt32(collection["ddlCarCompany"]);
                request.TotalPax = Convert.ToInt32(collection["ddlTotalPax"]);

                var resultsInfo = new ResultsInfo();

                CarServiceClient carSvc = new CarServiceClient();
                var result =
                    carSvc.SearchCarsByAirportCode(
                        new LoginHeader { UserName = "******", Password = "******", Culture = "en-US", Version = "1" },
                        request, out searchCarInfo, out resultsInfo);

                Session[sessionName] = searchCarInfo;

            }
            else
            {
                searchCarInfo = (SearchCarInfo[])Session[sessionName];
            }
            ViewBag.SessionId = sessionName;
            return View(searchCarInfo);
        }