SHA256
GuestLog - StayEntry - Initial Implementation
- Added new entity "StayEntry" to log stays of guests. - Added pages for StayEntry management (List and creation). - New DataList for PaymentMethods. - Other general changes and improvements.
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
@using Somnia.GuestLog.Models.DTOs;
|
||||
@using Somnia.GuestLog.Services
|
||||
|
||||
@inject ILogger<AddressQueryDialog> logger;
|
||||
@inject ISnackbar Snackbar
|
||||
@inject IGuestDocumentService guestDocumentService;
|
||||
|
||||
|
||||
<MudDialog Style="max-height: 90%;">
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h6">
|
||||
<MudIcon Icon="@Icons.Material.Filled.PersonSearch" Class="mr-3 mb-n1" />
|
||||
@LanguageLocale.control_GuestDocumentSearchDialog_dialogTitle
|
||||
</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
<GuestDocumentFilterForm @bind-Filter="@filter" />
|
||||
<MudButton StartIcon="@Icons.Material.Filled.Search" OnClick="BtnSearchGuestDocuments" FullWidth
|
||||
Variant="Variant.Filled" Disabled="@isLoading">
|
||||
@LanguageLocale.general_btnSearch
|
||||
</MudButton>
|
||||
<MudDivider DividerType="DividerType.FullWidth" Class="my-4" />
|
||||
|
||||
<MudPaper Class="pa-2" MinHeight="120px">
|
||||
@if (!isLoading && results.Count() == 0)
|
||||
{
|
||||
<MudText Typo="Typo.body1" Align="Align.Center">@LanguageLocale.general_noResults</MudText>
|
||||
}
|
||||
|
||||
@if (isLoading)
|
||||
{
|
||||
<MudSkeleton SkeletonType="SkeletonType.Rectangle" Height="100px" />
|
||||
}
|
||||
|
||||
@if (!isLoading)
|
||||
{
|
||||
<MudList T="GuestDocumentDTO" @bind-SelectedValue="SelectedResult"
|
||||
SelectionMode="SelectionMode.SingleSelection" Color="Color.Info">
|
||||
@foreach (GuestDocumentDTO result in results)
|
||||
{
|
||||
<MudListItem Value="result">
|
||||
<ChildContent>
|
||||
<MudTextField Value="@($"{result.DocumentType} - {result.DocumentNum}")"
|
||||
Label="@LanguageLocale.dto_GuestDocument_DocumentNum" ReadOnly />
|
||||
<MudTextField Value="@($"{result.Name} {result.Surname} {result.Surname2}")"
|
||||
Label="@LanguageLocale.dto_GuestDocument_Name" ReadOnly />
|
||||
</ChildContent>
|
||||
</MudListItem>
|
||||
}
|
||||
</MudList>
|
||||
}
|
||||
</MudPaper>
|
||||
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Cancel">
|
||||
@LanguageLocale.general_btnCancel
|
||||
</MudButton>
|
||||
<MudButton Color="Color.Primary" OnClick="btnSelectGuest">
|
||||
@LanguageLocale.control_GuestDocumentSearchDialog_btnSelectDocument
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
// Dialog Instance injected when open by the DialogService.
|
||||
// This field is null when dialog is not open by the DialogService.
|
||||
[CascadingParameter]
|
||||
private IMudDialogInstance MudDialog { get; set; } = null!;
|
||||
|
||||
|
||||
private GuestDocFilterDTO filter { get; set; } = new();
|
||||
private IEnumerable<GuestDocumentDTO> results = [];
|
||||
private GuestDocumentDTO? SelectedResult { get; set; }
|
||||
|
||||
private bool isLoading = false;
|
||||
|
||||
|
||||
private void Cancel() => MudDialog.Cancel();
|
||||
|
||||
private async Task BtnSearchGuestDocuments()
|
||||
{
|
||||
if (filter.IsEmpty)
|
||||
{
|
||||
Snackbar.Add("Add some search!", Severity.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
isLoading = true;
|
||||
results = await guestDocumentService.GetDtoListByFilterAsync(filter);
|
||||
isLoading = false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "GuestDocument Search returned an error!");
|
||||
Snackbar.Add($"Error searching: {ex.Message}", Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task btnSelectGuest()
|
||||
{
|
||||
if (SelectedResult is null)
|
||||
{
|
||||
Snackbar.Add("Select a guest document", Severity.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
DialogResult dialogResult = DialogResult.Ok<GuestDocumentDTO?>(SelectedResult);
|
||||
|
||||
//Close the dialog when opened by DialogService.
|
||||
logger.LogDebug("GuestDocumentSearchDialog - Closed MudDialogInstance!");
|
||||
MudDialog.Close(dialogResult);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user