Beispiel #1
0
 public void SelectBusStop(int selectedItemId, List <Station> stations, PredictorManager manager)
 {
     SelectedBusStop = stations.Find(f => f.Id == selectedItemId);
     if (((List <SelectListItem>)BusStops.Items).Any(a => a.Value == selectedItemId.ToString()))
     {
         ((List <SelectListItem>)BusStops.Items).FindAll(a => a.Value == selectedItemId.ToString())[0].Selected = true;
     }
     StationForecasts = manager.GetStationForecast(selectedItemId.ToString());
 }
Beispiel #2
0
        public ShowPredictBusStopViewModel(List <Station> stations, int selectedItemId, PredictorManager manager)
        {
            var list = new List <SelectListItem>();

            foreach (var item in stations)
            {
                var listItem = new SelectListItem()
                {
                    Text  = item.Name,
                    Value = item.Id.ToString()
                };
                if (item.Id == selectedItemId)
                {
                    listItem.Selected = true;
                }
                list.Add(listItem);
            }
            if (!list.Any(a => a.Selected))
            {
                list[0].Selected = true;
            }
            SelectedBusStop = stations.Find(f => f.Id == selectedItemId)
                              ?? stations.FirstOrDefault();
            StationForecasts = manager.GetStationForecast(selectedItemId.ToString());
        }