Skip to content

Commit

Permalink
Fixed appliance error
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruan-Rossouw committed Oct 25, 2023
1 parent 528b656 commit 108a09e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/apps/blazor-app/Components/Advanced/Variants.razor
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,11 @@ private async void IncrementAppliancePage(){
{
IncrementAppliance(defaultAppliance);
StateHasChanged();
} else {
}

@*
Impossible state I believe, however I am keeping this here just in case
else {
appliances.Add(new ApplianceModel
{
name = "Default",
Expand All @@ -348,9 +352,15 @@ private async void IncrementAppliancePage(){
powerUsage = power
});
StateHasChanged();
}
} *@
} else {
ApplianceModel? newModelGroup = appliances.FirstOrDefault(appliance => appliance.type == type && appliance.name == name && appliance.powerUsage == power);
double duration = 0;
if(defaultAppliance != null)
{
duration = defaultAppliance.durationUsed;
}

if(newModelGroup != null) {
IncrementAppliance(newModelGroup);
StateHasChanged();
Expand All @@ -360,7 +370,7 @@ private async void IncrementAppliancePage(){
name = name,
type = type,
quantity = 1,
durationUsed = 0,
durationUsed = duration,
powerUsage = power
});
StateHasChanged();
Expand Down

0 comments on commit 108a09e

Please sign in to comment.