public IHttpActionResult PostExcellaGetNearbyStation2(
        [FromBody]ExcellaGetNearbyStationRequest queryRequest)
        {
            var xmlData = new XmlDocument();
            var rootPath = HttpContext.Current.Server.MapPath("~/App_Data");
            //xmlData.LoadXml(new StreamReader(rootPath + "\\" + "TestData.xml").ReadToEnd());
            var xmlText = ExcellaGetEntrancesXMLText(queryRequest);
            HtmlDocument doc = new HtmlDocument();
            // doc.Load(rootPath + "\\" + "TestData.xml");
            doc.LoadHtml(xmlText);
            int countOfStations = 0;
            List<Station> listNearestStations = new List<Station>();
            foreach (var childNode in doc.DocumentNode.ChildNodes)
            {
                if (childNode.Name == "stationentrancesresp")
                {
                    foreach (var childrenNodes1 in childNode.ChildNodes)
                    {
                        if (childrenNodes1.Name == "entrances")
                        {
                            foreach (var childrenNodes2 in childrenNodes1.ChildNodes)
                            {
                                if (childrenNodes2.Name == "stationentrance")
                                {
                                    var nearestStationXML = new Station();
                                    foreach (var childrenNodes3 in childrenNodes2.ChildNodes)
                                    {
                                       
                                        //if (childrenNodes3.Name == "description")
                                        //{
                                        //    nearestStationXML.Name = childrenNodes3.InnerText;
                                        //}
                                       
                                        //if (childrenNodes3.Name == "lat")
                                        //{
                                        //    nearestStationXML.Lat = Convert.ToDouble(childrenNodes3.InnerText);
                                        //}
                                        //if (childrenNodes3.Name == "lon")
                                        //{
                                        //    nearestStationXML.Lon = Convert.ToDouble(childrenNodes3.InnerText);
                                        //}
                                        if (childrenNodes3.Name == "stationcode1")
                                        {
                                            listNearestStations.Add(StationsCollection.Stations.Where(x=>x.Code == childrenNodes3.InnerText).FirstOrDefault());
                                            countOfStations++;
                                             break;
                                            // nearestStationXML.Lon = Convert.ToDouble(childrenNodes3.InnerText);
                                        }
                                        //if (childrenNodes3.Name == "stationcode2")
                                        //{
                                        //    nearestStationXML.Lon = Convert.ToDouble(childrenNodes3.InnerText);
                                        //}

                                    }
                                    if (countOfStations >= 3)
                                    {
                                        break;
                                    }

                                }
                            }
                           
                           
                        }
                    }
                }
            }
            //foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href"))
            //{
            //    //HtmlAttribute att = link["href"];
            //    //att.Value = FixLink(att);
            //}
           // doc.Save("file.htm");

            //ExcellaGetEntrancesXML(queryRequest);
            //var nearestStation = StationsCollection.Stations
            // .Select(stn => AppHelper.Calc(queryRequest.latitude, queryRequest.longitude, stn.Lat, stn.Lon));
            //double distance = 0;
            //Station nearestStation = null;
            //foreach (var stationItem in StationsCollection.Stations)
            //{
            //    if (nearestStation == null)
            //    {
            //        nearestStation = stationItem;
            //        continue;
            //    }
            //    var newdistance = AppHelper.Calc(queryRequest.latitude, queryRequest.longitude, stationItem.Lat, stationItem.Lon);
            //    if (distance > newdistance)
            //    {
            //        nearestStation = stationItem;
            //    }

            //}
            var responseData = new ExcellaGetNearbyStationResponse();
            responseData.data = new Data();
            responseData.data.departures = new List<Departure>();
            foreach (var nS in listNearestStations)
            {
                responseData.data.departures.Add(new Departure() { destination = queryRequest.destination, line = nS.LineCode1, minutes = "30"});
            }
            //responseData.data.departures.Add(new Departure() { destination = queryRequest.destination, line = "SV", minutes = "30" });
            return Json(responseData);
        }
        public IHttpActionResult PostExcellaGetNearbyStation([FromBody]ExcellaGetNearbyStationRequest queryRequest)
        {
            //var nearestStation = StationsCollection.Stations
            // .Select(stn => AppHelper.Calc(queryRequest.latitude, queryRequest.longitude, stn.Lat, stn.Lon));
            double distance = 0;
            Station nearestStation = null;
            foreach (var stationItem in StationsCollection.Stations)
            {
                if (nearestStation == null)
                {
                    nearestStation = stationItem;
                    continue;
                }
                var newdistance = AppHelper.Calc(queryRequest.latitude, queryRequest.longitude, stationItem.Lat, stationItem.Lon);
                if (distance > newdistance)
                {
                    nearestStation = stationItem;
                }

            }
            var responseData = new ExcellaGetNearbyStationResponse();
            responseData.data = new Data();
            responseData.data.departures = new List<Departure>();
            responseData.data.departures.Add(new Departure() { destination = queryRequest.destination, line = "SV", minutes = "30" });
            return Json(responseData);
        }