-
+
@if (DeviceCopy is not null)
{
-
-
-
-
- Plug Settings
-
-
-
-
-
-
- Plug Name
-
-
- Here you can change the name of your plug
-
-
-
-
-
-
-
-
-
- Select Room
-
-
- Here you select or change the room the plug belongs to.
-
-
+
+
+
+
+ Plug Settings
+
+
+
+
+
+
+ Plug Name
+
+
+ Here you can change the name of your plug
+
+
+
+
+
+
+
+
+
+ Select Room
+
+
+ Here you select or change the room the plug belongs to.
+
+
-
-
+
+
}
@@ -145,6 +150,7 @@
bool hideButtonSettings = true;
int clicks = 0;
+ bool test = false;
double electricityPrice = 0;
@@ -160,11 +166,12 @@
plugs = getDevicesResult.Value;
}
- electricityPrice = MainDatabaseContext.EnergyPriceChanges.OrderByDescending(e=>e.DateTime).FirstOrDefault()?.EnergyPrice ?? 0;
+ electricityPrice = MainDatabaseContext.EnergyPriceChanges.OrderByDescending(e => e.DateTime).FirstOrDefault()?.EnergyPrice ?? 0;
}
private void Toggle(Device device)
{
+
if (device == SelectedDevice || clicks == 0)
{
hideButtonSettings = !hideButtonSettings;
@@ -176,7 +183,9 @@
{
SelectedDevice = device;
DeviceCopy = device.CopyDevice();
+ clicks = 0;
}
+
}
private async void OnSave()
@@ -184,10 +193,10 @@
if (hideButtonSettings)
{
MainDatabaseContext.ChangeTracker.Clear();
- MainDatabaseContext.EnergyPriceChanges.Add(new EnergyPriceChange(electricityPrice));
+ MainDatabaseContext.EnergyPriceChanges.Add(new EnergyPriceChange(electricityPrice));
await MainDatabaseContext.SaveChangesAsync();
}
- else if(DeviceCopy is not null && SelectedDevice is not null)
+ else if (DeviceCopy is not null && SelectedDevice is not null)
{
SelectedDevice.OverwiteDevice(DeviceCopy);
@@ -197,18 +206,18 @@
private async Task Delete(Device contextItem)
{
- bool succ = await MessageService.Confirm($"Do you really want to delete the device \"{contextItem.Name}\"?");
+ bool succ = await MessageService.Confirm($"Do you really want to delete the device \"{contextItem.Name}\"?");
- if(!succ)
+ if (!succ)
{
- return;
- }
+ return;
+ }
await DeviceManagmentService.UnregisterDevice(contextItem.MacAddress);
int index = plugs.FindIndex(x => x.MacAddress == contextItem.MacAddress);
- if(index != -1)
+ if (index != -1)
{
plugs.RemoveAt(index);
}