public ActionResult SetSelectedTank(SelectTankModel stm) { WaterSensorController.CurrentAquariumName = stm.SelectedTank.Text; //var tanks = Settings.Get().AquariumNames; //var slis = tanks.ToSelectListItems(); //var stm = new SelectTankModel { Tanks = slis }; return(PartialView("_SelectTank", stm)); }
public ActionResult _SelectTank() { var tanks = Settings.Get().AquariumNames; var selectedtank = tanks.Find(x => x.Name == WaterSensorController.CurrentAquariumName); var st = selectedtank.ToSelectListItem(); var slis = tanks.ToSelectListItems(); foreach (var tank in slis) { if (tank.Value == st.Value) { tank.Selected = true; break; } } var stm = new SelectTankModel { Tanks = slis, SelectedTank = st }; return(PartialView("_SelectTank", stm)); }