public List <D_CITY> GetCities(D_STATE State) { List <D_CITY> cities; if (State != null) { cities = Context.D_CITY.Where(x => x.StateID == State.ID).ToList(); } else { cities = Context.D_CITY.ToList(); } return(cities); }
private void LoadDDLs(int?selectedCity, int?selectedType) { try { D_STATE state = new D_STATE() { ID = Configuration.State }; List <D_CITY> cities = ApplicationContext.Current.Customers.GetCities(state); D_CITY emptyCity = new D_CITY() { ID = -1, Name = "" }; cities.Insert(0, emptyCity); ddlCities.DataSource = cities; ddlCities.DataValueField = "ID"; ddlCities.DataTextField = "Name"; if (selectedCity.HasValue) { ddlCities.SelectedValue = selectedCity.Value.ToString(); } ddlCities.DataBind(); List <D_ADDRESS_TYPE> types = ApplicationContext.Current.Customers.GetAddressTypeList(); D_ADDRESS_TYPE emptyType = new D_ADDRESS_TYPE() { ID = -1, Name = "" }; types.Insert(0, emptyType); ddlAddrType.DataSource = types; ddlAddrType.DataValueField = "ID"; ddlAddrType.DataTextField = "Name"; if (selectedType.HasValue) { ddlAddrType.SelectedValue = selectedType.Value.ToString(); } ddlAddrType.DataBind(); } catch (Exception ex) { writeError(ex.Message); } }
public List <D_CITY> GetCities(D_STATE State) { return(_customerDAO.GetCities(State)); }