SHA256
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:
@@ -14,7 +14,7 @@
|
||||
<PageTitle>Somnia - Guest Docs - Details</PageTitle>
|
||||
|
||||
<MudStack Row="true" Class="my-4">
|
||||
<MudText Typo="Typo.h4" GutterBottom="true">Guest Document - "@docId"</MudText>
|
||||
<MudText Typo="Typo.h4" GutterBottom="true">Guest Document: @docId - @documentModel?.FullDocument</MudText>
|
||||
<MudSpacer />
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Success" Size="Size.Small" StartIcon="@Icons.Material.Filled.Edit"
|
||||
OnClick="() => BtnEdit()" Disabled>
|
||||
@@ -77,7 +77,7 @@
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public string? docId { get; set; }
|
||||
public long docId { get; set; }
|
||||
|
||||
GuestDocForm _form = null!;
|
||||
|
||||
@@ -90,23 +90,8 @@
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
if (docId is null)
|
||||
{
|
||||
userMessage.ShowMessage("No GuestDocument provided!!", MessageKind.Error);
|
||||
Navigation.NotFound();
|
||||
return;
|
||||
}
|
||||
|
||||
GuestDocIdDTO? docIdModel = GuestDocIdDTO.DecodeFromString(docId);
|
||||
if (docIdModel is null)
|
||||
{
|
||||
userMessage.ShowMessage($"Provided GuestDocId can't be decoded: '{docId}'", MessageKind.Error);
|
||||
Navigation.NotFound();
|
||||
return;
|
||||
}
|
||||
|
||||
//Get model from db.
|
||||
documentModel = await guestDocService.GetDtoByIdAsync(docIdModel.DocumentType, docIdModel.DocumentNum);
|
||||
documentModel = await guestDocService.GetLastVersionDtoByIdAsync(docId);
|
||||
if (documentModel is null)
|
||||
{
|
||||
userMessage.ShowMessage($"GuestDocument not found with ID: '{docId}'", MessageKind.Error);
|
||||
@@ -123,13 +108,13 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (documentModel is null || documentModel.DocumentType is null || documentModel.DocumentNum is null)
|
||||
if (documentModel is null || documentModel.Id is null || documentModel.Version is null)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
guestStaysLoading = true;
|
||||
guestStayList = await stayService.GetStaysWithGuest(documentModel.DocumentType, documentModel.DocumentNum);
|
||||
guestStayList = await stayService.GetStaysWithGuest(documentModel.Id.Value);
|
||||
guestStaysLoading = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user