GuestLog - StayEntry detail view and improvements:

- Added detail view for StayEntries.
- Added button to delete StayEntries.
- Improve queries of StayEntries using a "query config" record.
- Enabled LazyLoading for all database relations. This will make easier to find cases where required relations aren't explicitly loaded.
This commit is contained in:
2026-08-17 21:28:26 +02:00
parent 3e0ef34f66
commit 67845e250f
15 changed files with 229 additions and 45 deletions
@@ -1,5 +1,5 @@
@using System.Diagnostics
@using FluentValidation;
@using Microsoft.AspNetCore.SignalR
@using Somnia.GuestLog.Models.DTOs;
@using Somnia.GuestLog.Services;
@using Somnia.GuestLog.Validators;
@@ -143,7 +143,7 @@
{
await _form.ValidateAsync();
if (Model.GuestDocuments.Count == 0)
if (Model.GuestDocuments is null || Model.GuestDocuments.Count == 0)
{
snackbar.Add("At least 1 guest is required!", MudBlazor.Severity.Warning);
return false;
@@ -198,12 +198,21 @@
}
//Check if this guest is already added.
bool alreadyAdded = Model.GuestDocuments.Any(e => e.DocumentType == resultData.DocumentType
&& e.DocumentNum == resultData.DocumentNum);
if (alreadyAdded)
if (Model.GuestDocuments is not null && Model.GuestDocuments.Count > 0)
{
snackbar.Add("GuestDocument already added!", MudBlazor.Severity.Warning);
return;
bool alreadyAdded = Model.GuestDocuments.Any(e => e.DocumentType == resultData.DocumentType
&& e.DocumentNum == resultData.DocumentNum);
if (alreadyAdded)
{
snackbar.Add("GuestDocument already added!", MudBlazor.Severity.Warning);
return;
}
}
//Init List.
if (Model.GuestDocuments is null)
{
Model.GuestDocuments = [];
}
Model.GuestDocuments.Add(resultData);
@@ -211,8 +220,12 @@
private void BtnDeleteGuest(string docType, string docNum)
{
Debug.Assert(Model.GuestDocuments is not null);
//Filter out given GuestDocument from model.
Model.GuestDocuments = Model.GuestDocuments.Where(e => !(e.DocumentType == docType && e.DocumentNum == docNum)).ToList();
Model.GuestDocuments = Model.GuestDocuments
.Where(e => !(e.DocumentType == docType && e.DocumentNum == docNum))
.ToList();
}
#endregion