Files
SomniaGuestLog/src/Somnia.GuestLog/Components/Pages/StayEntries/StayEntryDetail.razor
T

91 lines
2.6 KiB
Plaintext

@attribute [Route($"{GuestConsts.Page_StayEntry_Detail}")]
@using Somnia.GuestLog.Models.DTOs;
@using Somnia.GuestLog.Services;
@inject IUserMessageService userMessage
@inject IDialogService DialogService
@inject NavigationManager Navigation
@inject IGuestDocumentEntityService guestDocService
@inject IStayEntryEntityService stayService
<PageTitle>Somnia - Guest Docs - Details</PageTitle>
<MudStack Row="true" Class="my-4">
<MudText Typo="Typo.h4" GutterBottom="true">Stay Entry - "@StayId"</MudText>
<MudSpacer />
<MudButton Variant="Variant.Filled" Color="Color.Success" Size="Size.Small" StartIcon="@Icons.Material.Filled.Edit"
OnClick="() => BtnEdit()" Disabled>
@LanguageLocale.general_btnEdit
</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Default" Size="Size.Small"
StartIcon="@Icons.Material.Filled.ArrowBack" OnClick="() => BtnReturn()">
@LanguageLocale.general_btnReturn
</MudButton>
</MudStack>
@if (stayModel is not null)
{
<StayEntryForm Model="stayModel" FormMode="FormMode.ReadOnly" />
<MudText Class="mt-4">@CreateTimeString</MudText>
}
@code {
[Parameter]
public long StayId { get; set; }
[SupplyParameterFromQuery(Name = GuestConsts.QueryParam_ReturnUrl)]
public string? ReturnUrl { get; set; }
StayEntryDTO? stayModel = null;
private string? CreateTimeString
{
get
{
if (stayModel is null)
{
return null;
}
List<string> textList = [];
textList.Add($"Created at: {stayModel.CreateTime?.ToString() ?? "???"}");
textList.Add($"Last Update Time: {stayModel.UpdateTime?.ToString() ?? "???"}");
return string.Join("; ", textList);
}
}
protected override async Task OnInitializedAsync()
{
@* if (StayId is default)
{
Snackbar.Add("No Id provided!!", Severity.Error);
Navigation.NotFound();
return;
} *@
//Get model from db.
stayModel = await stayService.GetDtoByIdAsync(StayId, queryConfig: new(IncludeGuests: true));
if (stayModel is null)
{
userMessage.ShowMessage($"Stay not found with ID: '{StayId}'", MessageKind.Error);
Navigation.NotFound();
return;
}
}
private void BtnEdit()
{
userMessage.ShowMessage("Not implemented yet!", MessageKind.Info);
}
private void BtnReturn()
{
string uri = ReturnUrl ?? GuestConsts.Page_StayEntry_List;
Navigation.NavigateTo(uri);
}
}