Use loggings instead of lastloggings
This commit is contained in:
@@ -134,10 +134,6 @@ namespace Aperio_Control_Centre.ACSDatabase.Models
|
||||
[Display(Name = nameof(GatewayDevicesList))]
|
||||
public List<Device> GatewayDevicesList { get; } = [];
|
||||
|
||||
[NotMapped]
|
||||
public List<Logging> LastLoggings { get; } = [];
|
||||
|
||||
|
||||
|
||||
public uint OpenTimeDeciseconds()
|
||||
{
|
||||
|
||||
@@ -155,6 +155,7 @@ namespace Aperio_Control_Centre.Controllers
|
||||
.Where(d => d.Id == id)
|
||||
.Include(l => l.Location)
|
||||
.Include(d => d.DoorModeSchedules)
|
||||
.Include(l => l.Loggings!.OrderByDescending(t => t.Time).Take(25)).ThenInclude(u => u.User)
|
||||
.SingleOrDefaultAsync(token);
|
||||
|
||||
if (device == null)
|
||||
@@ -173,8 +174,6 @@ namespace Aperio_Control_Centre.Controllers
|
||||
device.LocationSelection = await db.Locations.LocationSelectList(token);
|
||||
device.TimezoneSelection = await db.Timezones.TimeZoneSelectList(token);
|
||||
device.DeviceGroupsSelectList.AddRange(await db.DeviceGroups.DeviceGroupsListItems(device, token));
|
||||
device.LastLoggings.AddRange(await db.Loggings.LastDeviceLoggings(device, 25, token));
|
||||
//device.DoorModes = (await db.Devices.FindAsync([device.Id], token))?.DoorModes;
|
||||
|
||||
this.CreateTitle();
|
||||
this.CreateReturnUrl(returnUrl);
|
||||
@@ -305,7 +304,7 @@ namespace Aperio_Control_Centre.Controllers
|
||||
deviceEdit.LocationSelection = await db.Locations.LocationSelectList(token);
|
||||
deviceEdit.TimezoneSelection = await db.Timezones.TimeZoneSelectList(token);
|
||||
deviceEdit.DeviceGroupsSelectList.AddRange(await db.DeviceGroups.DeviceGroupsListItems(deviceEdit, token));
|
||||
deviceEdit.LastLoggings.AddRange(await db.Loggings.LastDeviceLoggings(deviceEdit, 25, token));
|
||||
deviceEdit.Loggings = await db.Loggings.LastDeviceLoggings(deviceEdit, 25, token);
|
||||
deviceEdit.DoorModes = (await db.Devices.FindAsync([deviceEdit.Id], token))?.DoorModes;
|
||||
|
||||
ModelState.AddModelError(string.Empty, "Model invalid");
|
||||
|
||||
@@ -277,7 +277,7 @@
|
||||
}
|
||||
|
||||
|
||||
@if (Model.LastLoggings.Any())
|
||||
@if (Model.Loggings.Any())
|
||||
{
|
||||
<hr />
|
||||
<div class="row">
|
||||
@@ -286,29 +286,29 @@
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(m => m.LastLoggings.First().Time)
|
||||
@Html.DisplayNameFor(m => m.Loggings.First().Time)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(m => m.LastLoggings.First().Message)
|
||||
@Html.DisplayNameFor(m => m.Loggings.First().Message)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(m => m.LastLoggings.First().Access)
|
||||
@Html.DisplayNameFor(m => m.Loggings.First().Access)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(m => m.LastLoggings.First().User!.Name)
|
||||
@Html.DisplayNameFor(m => m.Loggings.First().User!.Name)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(m => m.LastLoggings.First().User!.PassNumber)
|
||||
@Html.DisplayNameFor(m => m.Loggings.First().User!.PassNumber)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(m => m.LastLoggings.First().UserName)
|
||||
@Html.DisplayNameFor(m => m.Loggings.First().UserName)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(m => m.LastLoggings.First().LogType)
|
||||
@Html.DisplayNameFor(m => m.Loggings.First().LogType)
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
@foreach (var item in Model.LastLoggings)
|
||||
@foreach (var item in Model.Loggings)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
Reference in New Issue
Block a user