public ActionResult AdjustBrightness(string id, string direction) { ViewBag.Title = title; SmartHouseContext shContext = LoadContext(); ISmartDevice dev = shContext.SmartHouse[id]; if (dev is IBrightable) { IBrightable thermo = dev as IBrightable; switch (direction) { case AdjustDirections.increase: thermo.IncreaseBrightness(); break; case AdjustDirections.decrease: thermo.DecreaseBrightness(); break; } } SmartHouseConfig shConfig = GetConfig(); SaveSmartHouse(shContext.SmartHouse); return(View("Index", shContext as object)); }
public ActionResult CreateDevice() { ViewBag.Title = title; SmartHouseContext shContext = LoadContext(); ISmartHouseCreator devCreator = Manufacture.GetManufacture(modelAssembly); string devType = Request.Params[CreateDeviceFields.devType]; string devName = Request.Params[CreateDeviceFields.name]; if (devName == "" || devName == null) { devName = CreateDevicePlaceholders.name; } ISmartDevice dev = devCreator.CreateDevice(devType, devName); if (dev != null) { FillIHaveThermostat(dev); FillIBrightable(dev); shContext.SmartHouse.AddDevice(dev); } SmartHouseConfig shConfig = GetConfig(); SaveSmartHouse(shContext.SmartHouse); return(View("Index", shContext as object)); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { if (Session["CurrentRoom"] != null) { int currentId = int.Parse(Session["CurrentRoom"].ToString()); using (SmartHouseContext context = new SmartHouseContext()) { context.Rooms.FirstOrDefault(r => r.Id == currentId).Name = RoomName.Text; context.SaveChanges(); Response.Redirect("Default.aspx"); } } else { } } else { if (Session["CurrentRoom"] != null) { int currentId = int.Parse(Session["CurrentRoom"].ToString()); Room currentRoom = null; using (SmartHouseContext context = new SmartHouseContext()) { currentRoom = context.Rooms.FirstOrDefault(r => r.Id == currentId); } RoomName.Text = currentRoom.Name; } else { } } }
public ActionResult EditRoom(string Name, int Id) { using (SmartHouseContext context = new SmartHouseContext()) { context.Rooms.FirstOrDefault(r => r.Id == Id).Name = Name; context.SaveChanges(); } return(RedirectToAction("RoomsList")); }
public ActionResult DeleteRoom(int id, string name) { using (SmartHouseContext context = new SmartHouseContext()) { context.Rooms.Remove(context.Rooms.FirstOrDefault(r => r.Id == id)); context.SaveChanges(); } return(RedirectToAction("RoomsList")); }
public InMemoryContextFixture() { var options = new DbContextOptionsBuilder <SmartHouseContext>() .UseInMemoryDatabase(databaseName: "Add_writes_to_database") .Options; Context = new SmartHouseContext(options); Context.Database.EnsureCreated(); }
public ActionResult EditRoom(int id) { Room room = null; using (SmartHouseContext context = new SmartHouseContext()) { room = context.Rooms.FirstOrDefault(r => r.Id == id); } return(View(room)); }
public ActionResult CreateRoom(string Name) { using (SmartHouseContext context = new SmartHouseContext()) { Room newRoom = new Room(Name); context.Rooms.Add(newRoom); context.SaveChanges(); } return(RedirectToAction("RoomsList")); }
public ActionResult ShowCreateDeviceForm(string selectDeviceType) { ViewBag.Title = title; SmartHouseContext shContext = LoadContext(); shContext.DevCreationContext = GetDeviceCreationContext(selectDeviceType); return(View("Index", shContext as object)); }
public ActionResult DeleteRoom(int id) { Room currentRoom = null; using (SmartHouseContext context = new SmartHouseContext()) { currentRoom = context.Rooms.FirstOrDefault(r => r.Id == id); } return(View(currentRoom)); }
public ActionResult Index(bool JsEnabled = true) { ViewBag.Title = title; if (JsEnabled) { ViewBag.JsEnabled = true; } SmartHouseContext shContext = LoadContext(); return(View(shContext as object)); }
public ActionResult RoomInfo(int Id) { Room room; SmartHouseContext context = new SmartHouseContext(); room = context.Rooms.FirstOrDefault(r => r.Id == Id); IDictionary <int, Device> DeviceList = GetDeviceList(room); Session["CurrentRoom"] = Id; ViewBag.CurrentRoom = Id; ViewBag.Counter = 0; return(View(DeviceList)); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { using (SmartHouseContext context = new SmartHouseContext()) { Room newRoom = new Room(InputForName.Text); context.Rooms.Add(newRoom); context.SaveChanges(); Response.Redirect("Default.aspx"); } } }
public ActionResult Delete(string id) { ViewBag.Title = title; SmartHouseContext shContext = LoadContext(); shContext.SmartHouse.RemoveDevice(id); SmartHouseConfig shConfig = GetConfig(); SaveSmartHouse(shContext.SmartHouse); return(View("Index", shContext as object)); }
protected void GetRoomsList() { List <Room> RoomsList = new List <Room>(); using (SmartHouseContext context = new SmartHouseContext()) { RoomsList = context.Rooms.ToList(); } foreach (Room room in RoomsList) { RoomControl c = (RoomControl)Page.LoadControl(@"~\Controls\RoomControl.ascx"); c.Initialize(room.Name, room.Id); PlaceHolder1.Controls.Add(c); } }
public ActionResult RoomsList() { if (Session["CurrentRoom"] != null) { Session["CurrentRoom"] = null; } else { } List <Room> RoomList; using (SmartHouseContext context = new SmartHouseContext()) { RoomList = context.Rooms.ToList(); } return(View(RoomList)); }
public ActionResult ToggleOpenClose(string id) { ViewBag.Title = title; SmartHouseContext shContext = LoadContext(); ISmartDevice dev = shContext.SmartHouse[id]; if (dev is IOpenCloseable) { (dev as IOpenCloseable).IsOpened ^= true; } SmartHouseConfig shConfig = GetConfig(); SaveSmartHouse(shContext.SmartHouse); return(View("Index", shContext as object)); }
private SmartHouseContext LoadContext() { ISmartHouse sh; SmartHouseContext shContext = new SmartHouseContext(); SmartHouseConfig shConfig = GetConfig(); sh = LoadSmartHouse(); if (sh == null) { sh = CreateTestSet(); SaveSmartHouse(sh); } shContext.SmartHouse = sh; shContext.TypesAvailable = LoadAvailableDevTypes(); shContext.DevCreationContext = null; return(shContext); }
public ActionResult TogglePower(string id) { ViewBag.Title = title; SmartHouseContext shContext = LoadContext(); switch (shContext.SmartHouse[id].State) { case EPowerState.On: shContext.SmartHouse[id].State = EPowerState.Off; break; case EPowerState.Off: shContext.SmartHouse[id].State = EPowerState.On; break; } SmartHouseConfig shConfig = GetConfig(); SaveSmartHouse(shContext.SmartHouse); return(View("Index", shContext as object)); }
protected void Page_Load(object sender, EventArgs e) { if (Session["CurrentRoom"] != null) { // this.create.ID = " " + "create"; using (SmartHouseContext context = new SmartHouseContext()) { int currentRoomId = int.Parse(Session["CurrentRoom"].ToString()); Room currentRoom = context.Rooms.FirstOrDefault(r => r.Id == currentRoomId); IDictionary <int, Device> deviceList = GetDeviceList(currentRoom); for (int i = 0; i < deviceList.Count; i++) { if (i % 3 == 0) { PlaceHolder1.Controls.Add(new LiteralControl("<div class=\"col-xs-12\">")); PlaceHolder1.Controls.Add(new LiteralControl("</div>")); } DeviceControl c = (DeviceControl)Page.LoadControl(@"~\Controls\DeviceControl.ascx"); Device dev = null; deviceList.TryGetValue(i, out dev); if (dev is Lamp) { Lamp dev1 = (Lamp)dev; c.Initialize(dev, currentRoomId); } else { c.Initialize(dev, currentRoomId); } PlaceHolder1.Controls.Add(c); } } } else { } }
public CommandService(SmartHouseContext smartHouseContext, IMapper mapper) { _smartHouseContext = smartHouseContext; _mapper = mapper; }
private string RegulateDevice(string onChange, bool sign, int id, string type, int roomId) { using (SmartHouseContext context = new SmartHouseContext()) { if (context.Conditioners.Any()) { if (type == context.Conditioners.FirstOrDefault().GetType().ToString()) { Conditioner device = context.Conditioners.Find(id); if (sign) { device.IncreeseTemperature(); } else { device.DecreeseTemperature(); } device.Room = context.Rooms.Find(roomId); context.SaveChanges(); return(device.CurrentTemperature.ToString()); } else { } } else { } if (context.Exhausters.Any()) { if (type == context.Exhausters.FirstOrDefault().GetType().ToString()) { Exhauster device = context.Exhausters.Find(id); if (sign) { device.IncreesePower(); } else { device.DecreesePower(); } device.Room = context.Rooms.Find(roomId); context.SaveChanges(); return(device.CurrentPower.ToString()); } else { } } else { } if (context.Fridges.Any()) { if (type == context.Fridges.FirstOrDefault().GetType().ToString()) { Fridge device = context.Fridges.Find(id); if (sign) { device.IncreeseTemperature(); } else { device.DecreeseTemperature(); } device.Room = context.Rooms.Find(roomId); context.SaveChanges(); return(device.CurrentTemperature.ToString()); } else { } } else { } if (context.Lamps.Any()) { if (type == context.Lamps.FirstOrDefault().GetType().ToString()) { Lamp device = context.Lamps.Find(id); if (sign) { device.IncreeseBrightness(); } else { device.DecreeseBrightness(); } device.Room = context.Rooms.Find(roomId); context.SaveChanges(); return(device.CurrentBrightness.ToString()); } else { } } else { } if (context.Radiators.Any()) { if (type == context.Radiators.FirstOrDefault().GetType().ToString()) { Radiator device = context.Radiators.Find(id); if (sign) { device.IncreeseTemperature(); } else { device.DecreeseTemperature(); } device.Room = context.Rooms.Find(roomId); context.SaveChanges(); return(device.CurrentTemperature.ToString()); } else { } } if (context.StereoSystems.Any()) { if (type == context.StereoSystems.FirstOrDefault().GetType().ToString()) { StereoSystem device = context.StereoSystems.Find(id); if (sign) { device.IncreeseVolume(); } else { device.DecreeseVolume(); } device.Room = context.Rooms.Find(roomId); context.SaveChanges(); return(device.CurrentVolume.ToString()); } else { } } else { } if (context.TVs.Any()) { if (type == context.TVs.FirstOrDefault().GetType().ToString()) { TV device = context.TVs.Find(id); if (onChange == "volume") { if (sign) { device.IncreeseVolume(); } else { device.DecreeseVolume(); } } else if (onChange == "channel") { if (sign) { device.NextChannel(); } else { device.PrevChannel(); } } else { if (sign) { device.IncreeseBrightness(); } else { device.DecreeseBrightness(); } } device.Room = context.Rooms.Find(roomId); context.SaveChanges(); if (onChange == "volume") { return(device.CurrentVolume.ToString()); } else if (onChange == "channel") { return(device.GetCurrentChannelName()); } else { return(device.CurrentBrightness.ToString()); } } else { } } else { } } return(null); }
private void CreateNewDevice(string type, string lampType, string name) { using (SmartHouseContext context = new SmartHouseContext()) { int id = (int)Session["CurrentRoom"]; switch (type) { case "Alarm": Alarm newAlarm = new Alarm(name); context.Rooms.FirstOrDefault(d => d.Id == id).Alarm.Add(newAlarm); break; case "Conditioner": Conditioner newConditioner = new Conditioner(name); context.Rooms.FirstOrDefault(d => d.Id == id).Conditioner.Add(newConditioner); break; case "Exhauster": Exhauster newExhauster = new Exhauster(name); context.Rooms.FirstOrDefault(d => d.Id == id).Exhauster.Add(newExhauster); break; case "Fridge": Fridge newFridge = new Fridge(name); context.Rooms.FirstOrDefault(d => d.Id == id).Fridge.Add(newFridge); break; case "Jalousie": Jalousie newJalousie = new Jalousie(name); context.Rooms.FirstOrDefault(d => d.Id == id).Jalousie.Add(newJalousie); break; case "Lamp": Lamp newLamp = new Lamp(name, lampType); context.Rooms.FirstOrDefault(d => d.Id == id).Lamp.Add(newLamp); break; case "Radiator": Radiator newRadiator = new Radiator(name); context.Rooms.FirstOrDefault(d => d.Id == id).Radiator.Add(newRadiator); break; case "Router": Router newRouter = new Router(name); context.Rooms.FirstOrDefault(d => d.Id == id).Router.Add(newRouter); break; case "StereoSystem": StereoSystem newStereoSystem = new StereoSystem(name); context.Rooms.FirstOrDefault(d => d.Id == id).StereoSystem.Add(newStereoSystem); break; case "TV": TV newTV = new TV(name); context.Rooms.FirstOrDefault(d => d.Id == id).TV.Add(newTV); break; default: Alarm newAlarma = new Alarm(name); context.Rooms.FirstOrDefault(d => d.Id == id).Alarm.Add(newAlarma); break; } context.SaveChanges(); } }
public HomeController(SmartHouseContext context, ISmartHouseRepository repository) { _context = context; _repository = repository; }
public DeviceTests(InMemoryContextFixture inMemoryContextFixture) { _smartHouseContext = inMemoryContextFixture.Context; }
private void RemoveDevice(int id, string type) { using (SmartHouseContext context = new SmartHouseContext()) { if (context.Alarms.Any()) { if (type == context.Alarms.FirstOrDefault().GetType().ToString()) { context.Alarms.Remove(context.Alarms.FirstOrDefault(d => d.Id == id)); context.SaveChanges(); return; } else { } } else { } if (context.Conditioners.Any()) { if (type == context.Conditioners.FirstOrDefault().GetType().ToString()) { context.Conditioners.Remove(context.Conditioners.FirstOrDefault(d => d.Id == id)); context.SaveChanges(); return; } else { } } else { } if (context.Exhausters.Any()) { if (type == context.Exhausters.FirstOrDefault().GetType().ToString()) { context.Exhausters.Remove(context.Exhausters.FirstOrDefault(d => d.Id == id)); context.SaveChanges(); return; } else { } } else { } if (context.Fridges.Any()) { if (type == context.Fridges.FirstOrDefault().GetType().ToString()) { context.Fridges.Remove(context.Fridges.FirstOrDefault(d => d.Id == id)); context.SaveChanges(); return; } else { } } else { } if (context.Jalousies.Any()) { if (type == context.Jalousies.FirstOrDefault().GetType().ToString()) { context.Jalousies.Remove(context.Jalousies.FirstOrDefault(d => d.Id == id)); context.SaveChanges(); return; } else { } } else { } if (context.Lamps.Any()) { if (type == context.Lamps.FirstOrDefault().GetType().ToString()) { context.Lamps.Remove(context.Lamps.FirstOrDefault(d => d.Id == id)); context.SaveChanges(); return; } else { } } else { } if (context.Radiators.Any()) { if (type == context.Radiators.FirstOrDefault().GetType().ToString()) { context.Radiators.Remove(context.Radiators.FirstOrDefault(d => d.Id == id)); context.SaveChanges(); return; } else { } } else { } if (context.Routers.Any()) { if (type == context.Routers.FirstOrDefault().GetType().ToString()) { context.Routers.Remove(context.Routers.FirstOrDefault(d => d.Id == id)); context.SaveChanges(); return; } else { } } else { } if (context.StereoSystems.Any()) { if (type == context.StereoSystems.FirstOrDefault().GetType().ToString()) { context.StereoSystems.Remove(context.StereoSystems.FirstOrDefault(d => d.Id == id)); context.SaveChanges(); return; } else { } } else { } if (context.TVs.Any()) { if (type == context.TVs.FirstOrDefault().GetType().ToString()) { context.TVs.Remove(context.TVs.FirstOrDefault(d => d.Id == id)); context.SaveChanges(); return; } else { } } else { } } return; }
private void RenameDevice(int id, string type, string name) { using (SmartHouseContext context = new SmartHouseContext()) { if (context.Alarms.Any()) { if (type == context.Alarms.FirstOrDefault().GetType().ToString()) { Alarm device = context.Alarms.Find(id); device.Name = name; device.Room = context.Rooms.Find(Session["CurrentRoom"]); context.SaveChanges(); return; } else { } } else { } if (context.Conditioners.Any()) { if (type == context.Conditioners.FirstOrDefault().GetType().ToString()) { Conditioner device = context.Conditioners.Find(id); device.Name = name; device.Room = context.Rooms.Find(Session["CurrentRoom"]); context.SaveChanges(); return; } else { } } else { } if (context.Exhausters.Any()) { if (type == context.Exhausters.FirstOrDefault().GetType().ToString()) { Exhauster device = context.Exhausters.Find(id); device.Name = name; device.Room = context.Rooms.Find(Session["CurrentRoom"]); context.SaveChanges(); return; } else { } } else { } if (context.Fridges.Any()) { if (type == context.Fridges.FirstOrDefault().GetType().ToString()) { Fridge device = context.Fridges.Find(id); device.Name = name; device.Room = context.Rooms.Find(Session["CurrentRoom"]); context.SaveChanges(); return; } else { } } else { } if (context.Jalousies.Any()) { if (type == context.Jalousies.FirstOrDefault().GetType().ToString()) { Jalousie device = context.Jalousies.Find(id); device.Name = name; device.Room = context.Rooms.Find(Session["CurrentRoom"]); context.SaveChanges(); return; } else { } } else { } if (context.Lamps.Any()) { if (type == context.Lamps.FirstOrDefault().GetType().ToString()) { Lamp device = context.Lamps.Find(id); device.Name = name; device.Room = context.Rooms.Find(Session["CurrentRoom"]); context.SaveChanges(); return; } else { } } else { } if (context.Radiators.Any()) { if (type == context.Radiators.FirstOrDefault().GetType().ToString()) { Radiator device = context.Radiators.Find(id); device.Name = name; device.Room = context.Rooms.Find(Session["CurrentRoom"]); context.SaveChanges(); return; } else { } } else { } if (context.Routers.Any()) { if (type == context.Routers.FirstOrDefault().GetType().ToString()) { Router device = context.Routers.Find(id); device.Name = name; device.Room = context.Rooms.Find(Session["CurrentRoom"]); context.SaveChanges(); return; } else { } } else { } if (context.StereoSystems.Any()) { if (type == context.StereoSystems.FirstOrDefault().GetType().ToString()) { StereoSystem device = context.StereoSystems.Find(id); device.Name = name; device.Room = context.Rooms.Find(Session["CurrentRoom"]); context.SaveChanges(); return; } else { } } else { } if (context.TVs.Any()) { if (type == context.TVs.FirstOrDefault().GetType().ToString()) { TV device = context.TVs.Find(id); device.Name = name; device.Room = context.Rooms.Find(Session["CurrentRoom"]); context.SaveChanges(); return; } else { } } else { } } return; }
private Device FindDevice(int id, string type) { Device device = null; using (SmartHouseContext context = new SmartHouseContext()) { if (context.Alarms.Any()) { if (type == context.Alarms.FirstOrDefault().GetType().ToString()) { return(device = context.Alarms.FirstOrDefault(d => d.Id == id)); } else { } } else { } if (context.Conditioners.Any()) { if (type == context.Conditioners.FirstOrDefault().GetType().ToString()) { return(device = context.Conditioners.FirstOrDefault(d => d.Id == id)); } else { } } else { } if (context.Exhausters.Any()) { if (type == context.Exhausters.FirstOrDefault().GetType().ToString()) { return(device = context.Exhausters.FirstOrDefault(d => d.Id == id)); } else { } } else { } if (context.Fridges.Any()) { if (type == context.Fridges.FirstOrDefault().GetType().ToString()) { return(device = context.Fridges.FirstOrDefault(d => d.Id == id)); } else { } } else { } if (context.Jalousies.Any()) { if (type == context.Jalousies.FirstOrDefault().GetType().ToString()) { return(device = context.Jalousies.FirstOrDefault(d => d.Id == id)); } else { } } else { } if (context.Lamps.Any()) { if (type == context.Lamps.FirstOrDefault().GetType().ToString()) { return(device = context.Lamps.FirstOrDefault(d => d.Id == id)); } else { } } else { } if (context.Radiators.Any()) { if (type == context.Radiators.FirstOrDefault().GetType().ToString()) { return(device = context.Radiators.FirstOrDefault(d => d.Id == id)); } else { } } else { } if (context.Routers.Any()) { if (type == context.Routers.FirstOrDefault().GetType().ToString()) { return(device = context.Routers.FirstOrDefault(d => d.Id == id)); } else { } } else { } if (context.StereoSystems.Any()) { if (type == context.StereoSystems.FirstOrDefault().GetType().ToString()) { return(device = context.StereoSystems.FirstOrDefault(d => d.Id == id)); } else { } } else { } if (context.TVs.Any()) { if (type == context.TVs.FirstOrDefault().GetType().ToString()) { return(device = context.TVs.FirstOrDefault(d => d.Id == id)); } else { } } else { } } return(device); }
public void Initialize(Device dev, int roomId) { string name = dev.Name; int id = dev.Id; string deviceType = dev.GetType().ToString(); bool state = dev.State; this.Label1.Text = "<h3 class=\"text-center\">" + name + "</h3>"; this.OnOff.Click += ButtonClick; this.OnOff.ID = "OnOff" + " " + id.ToString() + " " + deviceType + " " + roomId.ToString(); // this.CheckBox1.Attributes.Add("data-id", id.ToString()); // this.CheckBox1.CheckedChanged += ButtonClick; if (state) { // CheckBox1.Attributes.Add("checked", "true"); } else { } // this.CheckBox1.CssClass = "my-switch"; // this.CheckBox1.ID = id.ToString() + " " + "state" + " " + deviceType + " " + roomId.ToString(); // this.Label2.Attributes.Add("for", "MainContent_ctl00_" + id.ToString() + " " + "state" + " " + deviceType + " " + roomId.ToString()); //MainContent_ctl00_ //"ctl00$MainContent$ctl00$" this.Delete.Click += ButtonClick; this.Rename.Click += ButtonClick; this.Delete.ID = id.ToString() + " " + "delete" + " " + deviceType + " " + roomId.ToString(); this.Rename.ID = id.ToString() + " " + "rename" + " " + deviceType + " " + roomId.ToString(); using (SmartHouseContext context = new SmartHouseContext()) { if (context.Alarms.Any()) { if (deviceType == context.Alarms.FirstOrDefault().GetType().ToString()) { this.img.Attributes.Add("data-action", "Alarm"); this.img.Attributes.Add("data-on", "/Content/Images/Alarm_on.jpg"); this.img.Attributes.Add("data-off", "/Content/Images/Alarm.jpg"); if (state) { this.img.Attributes.Add("src", "/Content/Images/Alarm_on.jpg"); } else { this.img.Attributes.Add("src", "/Content/Images/Alarm.jpg"); } } else { } } else { } if (context.Conditioners.Any()) { if (deviceType == context.Conditioners.FirstOrDefault().GetType().ToString()) { img.Attributes.Add("data-action", "Conditioner"); img.Attributes.Add("data-on", "/Content/Images/Cond_on.jpg"); img.Attributes.Add("data-off", "/Content/Images/Cond.jpg"); if (state) { img.Attributes.Add("src", "/Content/Images/Cond_on.jpg"); } else { img.Attributes.Add("src", "/Content/Images/Cond.jpg"); } Conditioner dev2 = (Conditioner)dev; TemperatureDeviceBuilder(id, deviceType, roomId, dev2.CurrentTemperature); } else { } } else { } if (context.Exhausters.Any()) { if (deviceType == context.Exhausters.FirstOrDefault().GetType().ToString()) { img.Attributes.Add("data-action", "Exhauster"); img.Attributes.Add("data-on", "/Content/Images/Exhauster_on.jpg"); img.Attributes.Add("data-off", "/Content/Images/Exhauster.jpg"); if (state) { img.Attributes.Add("src", "/Content/Images/Exhauster_on.jpg"); } else { img.Attributes.Add("src", "/Content/Images/Exhauster.jpg"); } Exhauster dev2 = (Exhauster)dev; PowerDeviceBuilder(id, deviceType, roomId, dev2.CurrentPower); } else { } } else { } if (context.Fridges.Any()) { if (deviceType == context.Fridges.FirstOrDefault().GetType().ToString()) { img.Attributes.Add("data-action", "Fridge"); img.Attributes.Add("data-on", "/Content/Images/Fridge_on.jpg"); img.Attributes.Add("data-off", "/Content/Images/Fridge.jpg"); if (state) { img.Attributes.Add("src", "/Content/Images/Fridge_on.jpg"); } else { img.Attributes.Add("src", "/Content/Images/Fridge.jpg"); } Fridge dev2 = (Fridge)dev; TemperatureDeviceBuilder(id, deviceType, roomId, dev2.CurrentTemperature); } else { } } else { } if (context.Jalousies.Any()) { if (deviceType == context.Jalousies.FirstOrDefault().GetType().ToString()) { img.Attributes.Add("data-action", "Jalousie"); img.Attributes.Add("data-on", "/Content/Images/Jalousie.jpg"); img.Attributes.Add("data-off", "/Content/Images/Jalousie_off.jpg"); if (state) { img.Attributes.Add("src", "/Content/Images/Jalousie.jpg"); } else { img.Attributes.Add("src", "/Content/Images/Jalousie_off.jpg"); } } else { } } else { } if (context.Lamps.Any()) { if (deviceType == context.Lamps.FirstOrDefault().GetType().ToString()) { Lamp dev2 = (Lamp)dev; string lampType = dev2.LampType; img.Attributes.Add("data-action", "Lamp"); if (lampType == LampTypes.Chandelier.ToString()) { img.Attributes.Add("data-on", "/Content/Images/Lamp_on.jpg"); img.Attributes.Add("data-off", "/Content/Images/Lamp.jpg"); if (state) { img.Attributes.Add("src", "/Content/Images/Lamp_on.jpg"); } else { img.Attributes.Add("src", "/Content/Images/Lamp.jpg"); } } else if (lampType == LampTypes.Table.ToString()) { img.Attributes.Add("data-on", "/Content/Images/Lamp_table_on.jpg"); img.Attributes.Add("data-off", "/Content/Images/Lamp_table.jpg"); if (state) { img.Attributes.Add("src", "/Content/Images/Lamp_table_on.jpg"); } else { img.Attributes.Add("src", "/Content/Images/Lamp_table.jpg"); } } else if (lampType == LampTypes.Wall.ToString()) { img.Attributes.Add("data-on", "/Content/Images/Lamp_wall_on.jpg"); img.Attributes.Add("data-off", "/Content/Images/Lamp_wall.jpg"); if (state) { img.Attributes.Add("src", "/Content/Images/Lamp_wall_on.jpg"); } else { img.Attributes.Add("src", "/Content/Images/Lamp_wall.jpg"); } } else if (lampType == LampTypes.Floor.ToString()) { img.Attributes.Add("data-on", "/Content/Images/Lamp_floor_on.jpg"); img.Attributes.Add("data-off", "/Content/Images/Lamp_floor.jpg"); if (state) { img.Attributes.Add("src", "/Content/Images/Lamp_floor_on.jpg"); } else { img.Attributes.Add("src", "/Content/Images/Lamp_floor.jpg"); } } LightDeviceBuilder(id, deviceType, roomId, dev2.CurrentBrightness); } else { } } else { } if (context.Radiators.Any()) { if (deviceType == context.Radiators.FirstOrDefault().GetType().ToString()) { img.Attributes.Add("data-action", "Radiator"); img.Attributes.Add("data-on", "/Content/Images/Radiator_on.jpg"); img.Attributes.Add("data-off", "/Content/Images/Radiator.jpg"); if (state) { img.Attributes.Add("src", "/Content/Images/Radiator_on.jpg"); } else { img.Attributes.Add("src", "/Content/Images/Radiator.jpg"); } Radiator dev2 = (Radiator)dev; TemperatureDeviceBuilder(id, deviceType, roomId, dev2.CurrentTemperature); } else { } } else { } if (context.Routers.Any()) { if (deviceType == context.Routers.FirstOrDefault().GetType().ToString()) { img.Attributes.Add("data-action", "Router"); img.Attributes.Add("data-on", "/Content/Images/Router_on.jpg"); img.Attributes.Add("data-off", "/Content/Images/Router.jpg"); if (state) { img.Attributes.Add("src", "/Content/Images/Router_on.jpg"); } else { img.Attributes.Add("src", "/Content/Images/Router.jpg"); } } else { } } else { } if (context.StereoSystems.Any()) { if (deviceType == context.StereoSystems.FirstOrDefault().GetType().ToString()) { img.Attributes.Add("data-action", "StereoSystem"); img.Attributes.Add("data-on", "/Content/Images/StereoSystem_on.jpg"); img.Attributes.Add("data-off", "/Content/Images/StereoSystem.jpg"); if (state) { img.Attributes.Add("src", "/Content/Images/StereoSystem_on.jpg"); } else { img.Attributes.Add("src", "/Content/Images/StereoSystem.jpg"); } StereoSystem dev2 = (StereoSystem)dev; SoundDeviceBuilder(id, deviceType, roomId, dev2.CurrentVolume); } else { } } else { } if (context.TVs.Any()) { if (deviceType == context.TVs.FirstOrDefault().GetType().ToString()) { img.Attributes.Add("data-action", "TV"); img.Attributes.Add("data-on", "/Content/Images/TV_on.jpg"); img.Attributes.Add("data-off", "/Content/Images/TV.jpg"); if (state) { img.Attributes.Add("src", "/Content/Images/TV_on.jpg"); } else { img.Attributes.Add("src", "/Content/Images/TV.jpg"); } TV dev2 = (TV)dev; LightDeviceBuilder(id, deviceType, roomId, dev2.CurrentBrightness); SoundDeviceBuilder(id, deviceType, roomId, dev2.CurrentVolume); ChannelDeviceBuilder(id, deviceType, roomId, dev2.GetCurrentChannelName()); } else { } } else { } } }