public ActionResult AddRoom() { _house = ReadHouse(); _house.Remote.Reader.RoomData = Request.Params["addRoom[Room]"]; _house.Remote.Reader.CommandData = Request.Params["addRoom[Command]"]; _house.Remote.PushButton(); SaveHouse(); return PartialView("Device/Room", _house.GetRoom(_house.Remote.Reader.RoomData)); }
protected void Page_Load(object sender, EventArgs e) { btnRedactDev.Click += btnRedactDev_Click; _house = Master.Home; if (!IsPostBack) { ddlRedactRoom.DataSource = _house.Rooms.Values.Select(c => c.Name); ddlRedactRoom.DataBind(); ddlRoom.DataSource = _house.Rooms.Values.Select(c => c.Name); ddlRoom.DataBind(); ddlDevice.DataSource = _house.GetRoom(ddlRoom.SelectedValue).Devices.Values.Select(c => c.Name); ddlDevice.DataBind(); } }
public string Put([FromBody]DataToJson value) { _house = ReadHouse(); if (value.Device == "") { if (!_house.HasRoom(value.Room)) { _house.ChangeNameRoom(value.Value, value.Room); SaveHouse(); if (_house.GetRoom(value.Room) != null) { return "ok"; } } else { return "Комната \"" + value.Room + "\" уже существует"; } } else { if (!_house.HasDevice(value.Room, value.Device)) { _house.ChangeNameDevice(value.Room, value.Value, value.Device); SaveHouse(); if (_house.GetDevice(value.Room, value.Device) != null) { return "ok"; } } else { return "Устройство \"" + value.Device + "\" в комнате \" " + value.Room + " \" уже существует"; } } return "Изменение не произошло!!!"; }
public IEnumerable<string> Post([FromBody]DataToJson value) { _house = ReadHouse(); return _house.GetRoom(value.Room).Devices.Values.Select(c => c.Name); }
public ActionResult Devices(string id) { house = Session["home"] as House; if (house == null) return Redirect("/Home/Index"); ViewBag.RoomName = house.GetRoom(id).Name; ViewBag.Devices = new SelectList(house.GetRoom(id).Devices.Values, "Name", "Name"); GetView(); return View(view, house); }