Example #1
0
        /// <summary>
        /// RetrieveWardDataforLocality
        /// </summary>
        private static void RetrieveWardDataforLocality()
        {
            Console.WriteLine("Input Locality Name");
            string localityName = Console.ReadLine();

            WardData.Provider provider = new WardData.Provider();
            string            wardName = provider.RetrieveWard(localityName);

            Console.WriteLine("The ward name you belong is " + wardName);
        }
Example #2
0
        /// <summary>
        /// GetWard based on latitude and longitude
        /// </summary>
        /// <param name="latitude"></param>
        /// <param name="longitude"></param>
        /// <returns></returns>
        public string GetWard(string key1, string key2)
        {
            WardData.Provider rdr = new WardData.Provider();
            string ward = rdr.RetrieveWard(key1.Replace('_', '.'), key2.Replace('_', '.'));

            if (string.IsNullOrEmpty(ward))
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            return ward;
        }
Example #3
0
        /// <summary>
        /// GetWard based on latitude and longitude
        /// </summary>
        /// <param name="latitude"></param>
        /// <param name="longitude"></param>
        /// <returns></returns>
        public string GetWard(string key1, string key2)
        {
            WardData.Provider rdr  = new WardData.Provider();
            string            ward = rdr.RetrieveWard(key1.Replace('_', '.'), key2.Replace('_', '.'));

            if (string.IsNullOrEmpty(ward))
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            return(ward);
        }
Example #4
0
        /// <summary>
        /// RetrieveData
        /// </summary>
        private static void RetrieveWardDataforCordinates()
        {
            Console.WriteLine("Input Latitude");
            string latitude = Console.ReadLine();

            Console.WriteLine("Input Longitude");
            string longitude = Console.ReadLine();

            WardData.Provider provider = new WardData.Provider();
            string            wardName = provider.RetrieveWard(latitude, longitude);

            Console.WriteLine("The ward name you belong is " + wardName);
        }
Example #5
0
        /// <summary>
        /// PostSpotImageProcess
        /// </summary>
        public void PostSpotImageProcess()
        {
            var spotImages = context.SpotImages.Where(@w => @w.WardId == null && @w.UserAddress == null);

            WardData.Provider provider = new WardData.Provider();

            foreach (var spotImage in spotImages)
            {
                var ward = provider.RetrieveWard(spotImage.Latitude, spotImage.Longitude);
                spotImage.WardId = context.Wards.Where(@w => @w.Name == ward).First().Id;

                string   url = string.Format("http://maps.googleapis.com/maps/api/geocode/xml?latlng={0},{1}&sensor=false", spotImage.Latitude, spotImage.Longitude);
                XElement xml = XElement.Load(url);

                if (xml.Element("status").Value == "OK")
                {
                    spotImage.UserAddress = xml.Element("result").Element("formatted_address").Value;
                }
            }

            SubmitData();
        }
Example #6
0
        /// <summary>
        /// GetWard based on locality
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public string GetWard(string key)
        {
            var values = key.Split('|');

            if (values.Length > 0)
            {
                WardData.Provider rdr = new WardData.Provider();
                string method = values[0].ToLower();

                if (method == "zones")
                {
                    string zones = rdr.RetrieveZones();

                    if (string.IsNullOrEmpty(zones))
                    {
                        throw new HttpResponseException(HttpStatusCode.NotFound);
                    }

                    return zones;
                }
                else if (method == "wards")
                {
                    string data = values[1];
                    string wards = rdr.RetrieveWards(data);

                    if (string.IsNullOrEmpty(wards))
                    {
                        throw new HttpResponseException(HttpStatusCode.NotFound);
                    }

                    return wards;
                }
                else if (method == "ward")
                {
                    string data = values[1];
                    string ward = rdr.RetrieveWard(data);

                    if (string.IsNullOrEmpty(ward))
                    {
                        throw new HttpResponseException(HttpStatusCode.NotFound);
                    }

                    return ward;
                }
                else if(method == "locality")
                {
                    string data = values[1];
                    var localities = rdr.RetrieveLocalities(data);
                    StringBuilder localityList = new StringBuilder();

                    foreach (var locality in localities)
                    {
                        localityList.Append(locality.Name + ",");
                    }

                    if (localities == null)
                    {
                        throw new HttpResponseException(HttpStatusCode.NotFound);
                    }

                    return localityList.ToString();
                }                
            }

            return "100";
        }
Example #7
0
        /// <summary>
        /// RetrieveData
        /// </summary>
        private static void RetrieveWardDataforCordinates()
        {
            Console.WriteLine("Input Latitude");
            string latitude = Console.ReadLine();

            Console.WriteLine("Input Longitude");
            string longitude = Console.ReadLine();

            WardData.Provider provider = new WardData.Provider();
            string wardName = provider.RetrieveWard(latitude, longitude);
            Console.WriteLine("The ward name you belong is " + wardName);
        }
Example #8
0
        /// <summary>
        /// RetrieveWardDataforLocality
        /// </summary>
        private static void RetrieveWardDataforLocality()
        {
            Console.WriteLine("Input Locality Name");
            string localityName = Console.ReadLine();

            WardData.Provider provider = new WardData.Provider();
            string wardName = provider.RetrieveWard(localityName);
            Console.WriteLine("The ward name you belong is " + wardName);
        }
Example #9
0
        /// <summary>
        /// GetWard based on locality
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public string GetWard(string key)
        {
            var values = key.Split('|');

            if (values.Length > 0)
            {
                WardData.Provider rdr    = new WardData.Provider();
                string            method = values[0].ToLower();

                if (method == "zones")
                {
                    string zones = rdr.RetrieveZones();

                    if (string.IsNullOrEmpty(zones))
                    {
                        throw new HttpResponseException(HttpStatusCode.NotFound);
                    }

                    return(zones);
                }
                else if (method == "wards")
                {
                    string data  = values[1];
                    string wards = rdr.RetrieveWards(data);

                    if (string.IsNullOrEmpty(wards))
                    {
                        throw new HttpResponseException(HttpStatusCode.NotFound);
                    }

                    return(wards);
                }
                else if (method == "ward")
                {
                    string data = values[1];
                    string ward = rdr.RetrieveWard(data);

                    if (string.IsNullOrEmpty(ward))
                    {
                        throw new HttpResponseException(HttpStatusCode.NotFound);
                    }

                    return(ward);
                }
                else if (method == "locality")
                {
                    string        data         = values[1];
                    var           localities   = rdr.RetrieveLocalities(data);
                    StringBuilder localityList = new StringBuilder();

                    foreach (var locality in localities)
                    {
                        localityList.Append(locality.Name + ",");
                    }

                    if (localities == null)
                    {
                        throw new HttpResponseException(HttpStatusCode.NotFound);
                    }

                    return(localityList.ToString());
                }
            }

            return("100");
        }