public ActionResult FilterByRoom(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } ControlModel model = new ControlModel(); model.Buildings = db.Buildings.ToList(); Room filteringRoom = db.Rooms.Find(id); model.Floors = db.Floors.Where(floor => floor.BuildingID == filteringRoom.Floor.BuildingID).ToList(); model.Rooms = db.Rooms.Where(room => room.FloorID == filteringRoom.FloorID).ToList(); model.SelectedBuilding = filteringRoom.Floor.BuildingID; model.SelectedFloor = filteringRoom.FloorID; model.SelectedRoom = id; model.Devices = db.Devices.Where(device => device.RoomID == id).ToList(); return PartialView("Lists", model); }
public ActionResult FilterByFloor(int? id) { if (id == null) { return new HttpStatusCodeResult(HttpStatusCode.BadRequest); } ControlModel model = new ControlModel(); model.Buildings = db.Buildings.ToList(); Floor filteringFloor = db.Floors.Find(id); model.Floors = db.Floors.Where(floor => floor.BuildingID == filteringFloor.BuildingID).ToList(); model.Rooms = db.Rooms.Where(room => room.FloorID == id).ToList(); model.SelectedBuilding = filteringFloor.BuildingID; model.SelectedFloor = id; model.SelectedRoom = null; model.Devices = new System.Collections.Generic.List<Device>(); return PartialView("Lists", model); }
// GET: Control public ActionResult Index() { ControlModel model = new ControlModel(); model.Buildings = db.Buildings.ToList(); model.Floors = db.Floors.ToList(); model.Rooms = db.Rooms.ToList(); model.SelectedBuilding = null; model.SelectedFloor = null; model.SelectedRoom = null; model.Devices = new System.Collections.Generic.List<Device>(); ViewBag.List = model; return View(); }