/// <summary> /// Retrieve Localities /// </summary> private static void RetrieveLocalities() { Console.WriteLine("Input Locality Name"); string localityName = Console.ReadLine(); WardData.Provider provider = new WardData.Provider(); var localities = provider.RetrieveLocalities(localityName); foreach (var locality in localities) { Console.WriteLine(locality.Name); } }
/// <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"; }
/// <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"); }