Example #1
0
        public void InsertTopics()
        {
            string[]      sep    = new string[] { "," };
            IList <Topic> topics = new List <Topic>();

            Ward.Provider provider = new Ward.Provider();
            var           zones    = provider.RetrieveZones();

            if (zones != null && zones.Count() > 0)
            {
                foreach (var zone in zones.Split(sep, StringSplitOptions.RemoveEmptyEntries))
                {
                    var wards = provider.RetrieveWards(zone);

                    if (wards != null && wards.Count() > 0)
                    {
                        foreach (var ward in wards.Split(sep, StringSplitOptions.RemoveEmptyEntries))
                        {
                            Topic topic = new Topic
                            {
                                Id   = Guid.NewGuid(),
                                Name = zone.Replace('"', ' ').Trim() + "-" + ward.Replace('"', ' ').Trim()
                            };

                            topics.Add(topic);
                        }
                    }
                }
            }

            context.Topics.InsertAllOnSubmit(topics.AsEnumerable());
            SubmitData();
        }
Example #2
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 #3
0
        public void InsertTopics()
        {
            string[] sep = new string[] { "," };
            IList<Topic> topics = new List<Topic>();
            Ward.Provider provider = new Ward.Provider();
            var zones = provider.RetrieveZones();

            if (zones != null && zones.Count() > 0)
            {
                foreach (var zone in zones.Split(sep, StringSplitOptions.RemoveEmptyEntries))
                {
                    var wards = provider.RetrieveWards(zone);

                    if (wards != null && wards.Count() > 0)
                    {
                        foreach (var ward in wards.Split(sep, StringSplitOptions.RemoveEmptyEntries))
                        {
                            Topic topic = new Topic
                            {
                                Id = Guid.NewGuid(),
                                Name = zone.Replace('"', ' ').Trim() + "-" + ward.Replace('"', ' ').Trim()
                            };

                            topics.Add(topic);
                        }
                    }
                }
            }

            context.Topics.InsertAllOnSubmit(topics.AsEnumerable());
            SubmitData();
        }
Example #4
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");
        }