public CityListModel GetAllCitiesByState(CityListModel city) { CityListModel cityListModel = new CityListModel(); try { cityListModel.TableCity = null; var CityList = this.context?.TableCity.Where(x => x.StateId == city.StateId).ToList(); if (CityList.Count > 0) { cityListModel.TableCity = CityList; } cityListModel._tenantName = city._tenantName; cityListModel._token = city._token; cityListModel._failure = false; } catch (Exception es) { cityListModel._message = es.Message; cityListModel._failure = true; cityListModel._tenantName = city._tenantName; cityListModel._token = city._token; } return(cityListModel); }
public List <CityListModel> GetCityList() { string sql = "SELECT a.Name, a.NoOfDwellers, b.Name AS CountryDropDown FROM Cities a LEFT JOIN Countries b ON a.CountryID = b.Id ORDER BY a.Name ASC"; List <CityListModel> cityList = new List <CityListModel>(); SqlConnection connection = new SqlConnection(connectionString); connection.Open(); SqlCommand command = new SqlCommand(sql, connection); SqlDataReader reader = command.ExecuteReader(); int sl = 1; while (reader.Read()) { CityListModel aCityList = new CityListModel(); aCityList.Sl = sl++; aCityList.Name = reader["Name"].ToString(); aCityList.NoOfDwellers = Convert.ToInt32(reader["NoOfDwellers"].ToString()); aCityList.Country = reader["CountryDropDown"].ToString(); cityList.Add(aCityList); } connection.Close(); return(cityList); }
public ActionResult <CityListModel> GetAllCitiesByState(CityListModel city) { CityListModel cityListModel = new CityListModel(); try { cityListModel = _commonService.GetAllCitiesByState(city); } catch (Exception es) { cityListModel._failure = true; cityListModel._message = es.Message; } return(cityListModel); }
public CityListModel GetAllCitiesByState(CityListModel city) { CityListModel cityListModel = new CityListModel(); if (TokenManager.CheckToken(city._tenantName, city._token)) { cityListModel = this.commonRepository.GetAllCitiesByState(city); return cityListModel; } else { cityListModel._failure = true; cityListModel._message = TOKENINVALID; return cityListModel; } }
public Task SaveAsync(CityListModel model) { throw new NotImplementedException(); }