diff --git a/Components/Home/ServiceItem.razor b/Components/Home/ServiceItem.razor
index 7fe591f..e14b943 100644
--- a/Components/Home/ServiceItem.razor
+++ b/Components/Home/ServiceItem.razor
@@ -17,12 +17,12 @@
{
@if (id is null)
{
-
+
}
else
{
-
+
}
}
diff --git a/Components/Home/ServiceItem.razor.cs b/Components/Home/ServiceItem.razor.cs
index 069c573..af4e113 100644
--- a/Components/Home/ServiceItem.razor.cs
+++ b/Components/Home/ServiceItem.razor.cs
@@ -3,6 +3,7 @@
using System.Diagnostics.CodeAnalysis;
using Event;
using Microsoft.AspNetCore.Components;
+using Microsoft.EntityFrameworkCore;
using Services;
public partial class ServiceItem {
@@ -11,25 +12,26 @@ public partial class ServiceItem {
[EditorRequired]
public RegionService? RegionService { get; set; }
- private EventType status { get; set; }
+ private EventType type { get; set; }
private bool future { get; set; }
private int? id { get; set; }
- protected override Task OnParametersSetAsync() {
- var res = this.RegionService.Events
+ protected override async Task OnParametersSetAsync() {
+ var res = await this.db.EventRegionService
+ .Where(x => x.RegionServiceId == this.RegionService.Id)
+ .Select(x => x.Event)
.Where(x =>
(x.Type == EventType.Maintenance || x.End == null) &&
x.Status != EventStatus.Completed &&
x.Status != EventStatus.Resolved &&
x.Status != EventStatus.Cancelled)
- .MaxBy(x => x.Type);
+ .OrderByDescending(x => x.Type)
+ .FirstOrDefaultAsync();
this.id = res?.Id;
- this.status = res?.Type ?? default;
+ this.type = res?.Type ?? default;
this.future = res?.Start.ToUniversalTime() > DateTime.UtcNow;
-
- return Task.CompletedTask;
}
}