private List <System.Web.Mvc.SelectListItem> LoadWeatherStations(long?weatherStationId = null, WeatherStation weatherStation = null) { WeatherStationConfiguration wsc = new WeatherStationConfiguration(); List <WeatherStation> weatherStations = wsc.GetAllWeatherStations(); List <System.Web.Mvc.SelectListItem> result = new List <SelectListItem>(); foreach (var item in weatherStations) { bool isSelected = false; if (weatherStation != null && weatherStationId.HasValue) { isSelected = (weatherStation.WeatherStationId == weatherStationId); } SelectListItem sl = new SelectListItem() { Value = item.WeatherStationId.ToString(), Text = item.Name, Selected = isSelected }; result.Add(sl); } return(result); }
private List <System.Web.Mvc.SelectListItem> LoadWeatherStation(long?weatherStationId = null, Farm farm = null) { WeatherStationConfiguration rc = new WeatherStationConfiguration(); List <WeatherStation> weatherStationConfiguration = rc.GetAllWeatherStations(); List <System.Web.Mvc.SelectListItem> result = new List <SelectListItem>(); foreach (var item in weatherStationConfiguration) { bool isSelected = false; SelectListItem sl = new SelectListItem() { Value = item.WeatherStationId.ToString(), Text = item.Name, Selected = isSelected }; result.Add(sl); } return(result); }