GuestDocument Versions - Part 1:

- Changed GuestDocument PK from `DocumentType`+`DocumentNumber` to to `ID`+`Version` for future versioning.
- Added DB field "IsLastVersion" to simplify queries where only last/current version is allowed.
- Updated GuestDocument DB fields type for `CreateTime` & `UpdateTime` to add precision.
- Updated usages of GuestDocument PK to new PK.
- Limit delete of a GuestDocument when it's currently used in a StayEntry.

Note: DB changes require recreating db tables, so all data is lost and migration "rollback" is not allowed.
This commit is contained in:
Daniel-Garmig committed 2026-09-01 15:04:38 +02:00
1 parent a01eed82e1
commit 887c3d787a
21 files changed
+525 -93

No files matched your search

@@ -95,7 +95,7 @@
{
<MudTd DataLabel="@LanguageLocale.general_actions">
<MudIconButton Icon="@Icons.Material.Filled.Delete"
OnClick="@(() => BtnDeleteGuest(context.DocumentType!, context.DocumentNum!))" />
OnClick="@(() => BtnDeleteGuest(context.Id!.Value, context.Version!.Value))" />
</MudTd>
}
@if (ReadOnly)
@@ -229,8 +229,7 @@
//Check if this guest is already added.
if (Model.GuestDocuments.Count > 0)
{
bool alreadyAdded = Model.GuestDocuments.Any(e => e.DocumentType == resultData.DocumentType
&& e.DocumentNum == resultData.DocumentNum);
bool alreadyAdded = Model.GuestDocuments.Any(e => e.Id == resultData.Id);
if (alreadyAdded)
{
userMessage.ShowMessage("GuestDocument already added!", MessageKind.Warning);
@@ -241,13 +240,13 @@
Model.GuestDocuments.Add(resultData);
}
private void BtnDeleteGuest(string docType, string docNum)
private void BtnDeleteGuest(long guestDocId, int version)
{
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))
.Where(e => !(e.Id == guestDocId && e.Version == version))
.ToList();
}