SHA256
Compare commits
34
Commits
| Author | SHA256 | Date | |
|---|---|---|---|
|
|
9ec87d56da | ||
|
|
7b8020879b | ||
|
|
dc5293bdf7 | ||
|
|
4b72e3b3d3 | ||
|
|
6fe5a5e5a3 | ||
|
|
058352b7f3 | ||
|
|
313a714a99 | ||
|
|
cf31cbc414 | ||
|
|
b318f2415c | ||
|
|
c24faedee5 | ||
|
|
7052ec734c | ||
|
|
887c3d787a | ||
|
|
a01eed82e1 | ||
|
|
b08aaf2d7b | ||
|
|
4f22cd4541 | ||
|
|
b18bd7caa6 | ||
|
|
511bd023f2 | ||
|
|
0de4e1ba10 | ||
|
|
340bc583b7 | ||
|
|
67845e250f | ||
|
|
3e0ef34f66 | ||
|
|
6dc2d2426b | ||
|
|
ec7efd867b | ||
|
|
8232e7d7c9 | ||
|
|
5c7fed2677 | ||
|
|
3fe558c231 | ||
|
|
2335c223ea | ||
|
|
a5eea09eee | ||
|
|
5061f9362b | ||
|
|
e7e9fb1d12 | ||
|
|
d93ba3d9ee | ||
|
|
9f44ff6e3d | ||
|
|
76b2695c02 | ||
|
|
86fadf97b4 |
@@ -0,0 +1,21 @@
|
||||
<Project>
|
||||
<PropertyGroup>
|
||||
<!-- Required for intellisense -->
|
||||
<CoreCompileDependsOn>CoreResGen;$(CoreCompileDependsOn)</CoreCompileDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource
|
||||
Update="@(EmbeddedResource -> WithMetadataValue('Generator', 'MSBuild:Compile'))"
|
||||
Type="Resx">
|
||||
<StronglyTypedFileName>$(IntermediateOutputPath)\$([MSBuild]::ValueOrDefault('%(RelativeDir)',
|
||||
'').Replace('\', '.').Replace('/',
|
||||
'.'))%(Filename).g$(DefaultLanguageSourceExtension)</StronglyTypedFileName>
|
||||
<StronglyTypedLanguage>$(Language)</StronglyTypedLanguage>
|
||||
<StronglyTypedNamespace Condition="'%(RelativeDir)' == ''">$(RootNamespace)</StronglyTypedNamespace>
|
||||
<StronglyTypedNamespace Condition="'%(RelativeDir)' != ''">$(RootNamespace).$([MSBuild]::ValueOrDefault('%(RelativeDir)',
|
||||
'').Replace('\', '.').Replace('/', '.').TrimEnd('.'))</StronglyTypedNamespace>
|
||||
<StronglyTypedClassName>%(Filename)</StronglyTypedClassName>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -6,7 +6,11 @@
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageVersion Include="Extensions.MudBlazor.StaticInput" Version="4.1.0" />
|
||||
<PackageVersion Include="FluentStorage" Version="8.0.16" />
|
||||
<PackageVersion Include="FluentStorage.AWS" Version="8.0.10" />
|
||||
<PackageVersion Include="FluentValidation" Version="12.1.1" />
|
||||
<PackageVersion Include="Grpc.AspNetCore" Version="2.64.0" />
|
||||
<PackageVersion Include="Microsoft.Extensions.Localization" Version="10.0.9" />
|
||||
<PackageVersion Include="MudBlazor" Version="9.4.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -21,6 +25,7 @@
|
||||
</PackageVersion>
|
||||
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.7" />
|
||||
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.7" />
|
||||
<PackageVersion Include="Microsoft.EntityFrameworkCore.Proxies" Version="10.0.7" />
|
||||
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,4 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
@using System.Globalization
|
||||
@using Microsoft.AspNetCore.Localization
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
@@ -20,6 +23,22 @@
|
||||
<ReconnectModal />
|
||||
<script src="@Assets["_framework/blazor.web.js"]"></script>
|
||||
<script src="@Assets["_content/MudBlazor/MudBlazor.min.js"]"></script>
|
||||
<script src="js/App.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@code {
|
||||
[CascadingParameter]
|
||||
private HttpContext? HttpContext { get; set; }
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
HttpContext?.Response.Cookies.Append(
|
||||
CookieRequestCultureProvider.DefaultCookieName,
|
||||
CookieRequestCultureProvider.MakeCookieValue(
|
||||
new RequestCulture(
|
||||
CultureInfo.CurrentCulture,
|
||||
CultureInfo.CurrentUICulture)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
@using Somnia.GuestLog.Models.DTOs;
|
||||
@using Somnia.GuestLog.Services
|
||||
@using Somnia.GuestLog.Services.AddressQuery;
|
||||
|
||||
@inject ILogger<AddressQueryDialog> logger;
|
||||
@inject IAddressQueryFactory addressQueryFactory;
|
||||
@inject IUserMessageService userMessage
|
||||
|
||||
<MudDialog @ref="@DialogRef">
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h6">
|
||||
<MudIcon Icon="@Icons.Material.Filled.NotListedLocation" Class="mr-3 mb-n1" />
|
||||
@LanguageLocale.control_AddressQueryDialog_dialogTitle
|
||||
</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
<MudStack row>
|
||||
<MudTextField @bind-Value="SearchText" Label="@LanguageLocale.control_AddressQueryDialog_searchText"
|
||||
Required />
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Search" OnClick="btnSearchAddress" />
|
||||
</MudStack>
|
||||
|
||||
<MudPaper Class="mt-4 pa-2">
|
||||
@if (addressResults.Count == 0)
|
||||
{
|
||||
<MudText Typo="Typo.body1">@LanguageLocale.general_noResults</MudText>
|
||||
}
|
||||
|
||||
<MudList T="AddressResultDTO" @bind-SelectedValue="SelectedAddressResult"
|
||||
SelectionMode="SelectionMode.SingleSelection" Color="Color.Info">
|
||||
@foreach (AddressResultDTO result in addressResults)
|
||||
{
|
||||
<MudListItem Value="result">
|
||||
<ChildContent>
|
||||
<MudTextField Value="@($"{result.AddressRoad}, {result.HouseNumber}")"
|
||||
Label="@LanguageLocale.general_address_address" ReadOnly />
|
||||
<MudStack row>
|
||||
<MudTextField Value="@result.AddressCity" Label="@LanguageLocale.general_address_city"
|
||||
ReadOnly />
|
||||
<MudTextField Value="@result.AddressProvince"
|
||||
Label="@LanguageLocale.general_address_province" ReadOnly />
|
||||
<MudTextField Value="@result.AddressState" Label="@LanguageLocale.general_address_state"
|
||||
ReadOnly />
|
||||
</MudStack>
|
||||
<MudStack row>
|
||||
<MudTextField Value="@result.AddressCountry" Label="@LanguageLocale.general_address_country"
|
||||
ReadOnly />
|
||||
<MudTextField Value="@result.ZipCode" Label="@LanguageLocale.general_address_zipCode"
|
||||
ReadOnly />
|
||||
</MudStack>
|
||||
</ChildContent>
|
||||
</MudListItem>
|
||||
}
|
||||
</MudList>
|
||||
</MudPaper>
|
||||
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="Cancel">
|
||||
@LanguageLocale.general_btnCancel
|
||||
</MudButton>
|
||||
<MudButton Color="Color.Primary" OnClick="btnSelectAddress">
|
||||
@LanguageLocale.control_AddressQueryDialog_btnSelectAddress
|
||||
</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!;
|
||||
// Reference to the Dialog when open by the ShowAsync Method. (When dialog is used inline).
|
||||
// This field is null when dialog is not open using the internal methods.
|
||||
private IDialogReference? _reference;
|
||||
|
||||
//Reference to the MudDialog component. Used to manage the internal dialog when the component is inline.
|
||||
private MudDialog DialogRef { get; set; } = null!;
|
||||
|
||||
private string SearchText { get; set; } = "";
|
||||
private List<AddressResultDTO> addressResults = [];
|
||||
private AddressResultDTO? SelectedAddressResult { get; set; }
|
||||
|
||||
|
||||
private void Cancel()
|
||||
{
|
||||
if (MudDialog is not null)
|
||||
{
|
||||
MudDialog.Cancel();
|
||||
return;
|
||||
}
|
||||
else if (_reference is not null)
|
||||
{
|
||||
DialogRef.CloseAsync(DialogResult.Cancel());
|
||||
return;
|
||||
}
|
||||
throw new InvalidOperationException("Unable to cancel (close) the dialog!");
|
||||
}
|
||||
|
||||
private async Task btnSearchAddress()
|
||||
{
|
||||
if (SearchText.Length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var queryService = addressQueryFactory.GetService();
|
||||
|
||||
addressResults = await queryService.SearchAddressAsync(SearchText);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "SearchAddress returned an error!");
|
||||
userMessage.ShowMessage($"Error searching address: {ex.Message}", MessageKind.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task btnSelectAddress()
|
||||
{
|
||||
if (SelectedAddressResult is null)
|
||||
{
|
||||
userMessage.ShowMessage("Select an address", MessageKind.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
DialogResult dialogResult = DialogResult.Ok<AddressResultDTO?>(SelectedAddressResult);
|
||||
|
||||
//Close the dialog when opened by DialogService.
|
||||
if (MudDialog != null)
|
||||
{
|
||||
logger.LogDebug("AddressQueryDialog - Closed MudDialogInstance!");
|
||||
MudDialog.Close(dialogResult);
|
||||
return;
|
||||
}
|
||||
//Close the dialog when is a Inline dialog.
|
||||
else if (_reference is not null)
|
||||
{
|
||||
logger.LogDebug("AddressQueryDialog - Closed inline dialog instance!");
|
||||
await DialogRef.CloseAsync(dialogResult);
|
||||
return;
|
||||
}
|
||||
//Throw if the dialog can't be closed (as none of the above is true).
|
||||
throw new InvalidOperationException("Dialog cannot be closed! No reference to close!");
|
||||
}
|
||||
|
||||
|
||||
public async Task<IDialogReference> ShowAsync(DialogOptions? options = null)
|
||||
{
|
||||
_reference = await DialogRef.ShowAsync(options: options);
|
||||
return _reference;
|
||||
}
|
||||
|
||||
public async Task CloseAsync()
|
||||
{
|
||||
await DialogRef.CloseAsync();
|
||||
_reference = null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<MudMessageBox @ref="_msgBox" Title="@LanguageLocale.general_confirmTitle"
|
||||
CancelText="@LanguageLocale.general_btnCancel">
|
||||
<MessageContent>
|
||||
@LanguageLocale.general_confirmDeleteMsg
|
||||
</MessageContent>
|
||||
<YesButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Error" StartIcon="@Icons.Material.Filled.DeleteForever">
|
||||
@LanguageLocale.general_btnDelete
|
||||
</MudButton>
|
||||
</YesButton>
|
||||
</MudMessageBox>
|
||||
|
||||
@code {
|
||||
public MudMessageBox MsgBox => _msgBox;
|
||||
|
||||
MudMessageBox _msgBox = null!;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
@using Somnia.GuestLog.Models.DTOs
|
||||
|
||||
<MudDialog>
|
||||
<TitleContent>
|
||||
GuestDocument Details
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
<GuestDocForm Model="@DocumentDTO" ReadOnly=true />
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Color="Color.Primary" Variant="Variant.Filled" EndIcon="@Icons.Material.Filled.Close"
|
||||
OnClick="Submit">
|
||||
@LanguageLocale.general_btnClose
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
[CascadingParameter]
|
||||
private IMudDialogInstance MudDialog { get; set; } = null!;
|
||||
|
||||
[Parameter]
|
||||
public GuestDocumentDTO DocumentDTO { get; set; } = new();
|
||||
|
||||
private void Submit() => MudDialog.Close(DialogResult.Ok(true));
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
@using Somnia.GuestLog.Models.DTOs;
|
||||
@using Somnia.GuestLog.Services
|
||||
@using Somnia.GuestLog.Services.Entity
|
||||
|
||||
@inject ILogger<AddressQueryDialog> logger;
|
||||
@inject IUserMessageService userMessage
|
||||
@inject IGuestDocumentEntityService 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)
|
||||
{
|
||||
@* Only show on first load *@
|
||||
@if (loadCount == 1)
|
||||
{
|
||||
<MudText Align="Align.Center" GutterBottom>
|
||||
@LanguageLocale.control_GuestDocumentSearchDialog_txtSuggestedGuests
|
||||
</MudText>
|
||||
}
|
||||
|
||||
<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()
|
||||
{
|
||||
OnlyLastVersion = true
|
||||
};
|
||||
private IEnumerable<GuestDocumentDTO> results = [];
|
||||
private GuestDocumentDTO? SelectedResult { get; set; }
|
||||
|
||||
private bool isLoading = false;
|
||||
private int loadCount = 0;
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
//Load last 5 guests.
|
||||
await LoadGuests(limit: 5);
|
||||
}
|
||||
|
||||
|
||||
private void Cancel() => MudDialog.Cancel();
|
||||
|
||||
|
||||
private async Task LoadGuests(int limit = 25)
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
isLoading = true;
|
||||
results = await guestDocumentService.GetDtoListByFilterAsync(filter);
|
||||
isLoading = false;
|
||||
loadCount++;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex, "GuestDocument Search returned an error!");
|
||||
userMessage.ShowMessage($"Error searching: {ex.Message}", MessageKind.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
private async Task BtnSearchGuestDocuments()
|
||||
{
|
||||
if (filter.IsEmpty)
|
||||
{
|
||||
userMessage.ShowMessage("Search can't be empty!", MessageKind.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
//Load unlimited guests using current filter.
|
||||
await LoadGuests();
|
||||
}
|
||||
|
||||
private async Task btnSelectGuest()
|
||||
{
|
||||
if (SelectedResult is null)
|
||||
{
|
||||
userMessage.ShowMessage("A guest document must be selected", MessageKind.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
DialogResult dialogResult = DialogResult.Ok<GuestDocumentDTO?>(SelectedResult);
|
||||
|
||||
//Close the dialog when opened by DialogService.
|
||||
logger.LogDebug("GuestDocumentSearchDialog - Closed MudDialogInstance!");
|
||||
MudDialog.Close(dialogResult);
|
||||
return;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<MudDialog>
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.subtitle1" Align="Align.Center">@LanguageLocale.general_inProgressMsg</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
<div class="d-flex flex-grow-1 flex-wrap justify-center align-center ma-8">
|
||||
<MudProgressCircular Indeterminate="true" Color="Color.Primary" Size="Size.Large"/>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</MudDialog>
|
||||
|
||||
@code {
|
||||
[CascadingParameter]
|
||||
private IMudDialogInstance MudDialog { get; set; } = null!;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
var updatedOptions = MudDialog.Options with
|
||||
{
|
||||
BackdropClick = false,
|
||||
CloseButton = false,
|
||||
CloseOnEscapeKey = false,
|
||||
CloseOnNavigation = true,
|
||||
FullWidth = true,
|
||||
};
|
||||
await MudDialog.SetOptionsAsync(updatedOptions);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
@using System.Linq;
|
||||
@using FluentValidation;
|
||||
@using Somnia.GuestLog.Models.DTOs;
|
||||
@using Somnia.GuestLog.Services;
|
||||
@using Somnia.GuestLog.Validators;
|
||||
|
||||
@inject IDataListService dataListService;
|
||||
@inject IValidator<GuestDocumentDTO> guestDocValidator;
|
||||
|
||||
|
||||
<MudForm @ref="@_form" Model="@Model" Validation="@((guestDocValidator as GuestDocumentDTOValidator)!.ValidateValue)" ValidationDelay="0"
|
||||
ReadOnly="@ReadOnly">
|
||||
<MudGrid>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudPaper Class="pa-4" Elevation="3" Height="100%">
|
||||
<MudText Typo="Typo.subtitle1" Align="Align.Center">@LanguageLocale.control_GuestDocForm_sectionDocument</MudText>
|
||||
<MudDivider DividerType="DividerType.Middle" Class="mb-4" />
|
||||
<MudStack Row style="@FieldMarginY">
|
||||
<MudSelect @bind-Value="Model.DocumentType" For="@(() => Model.DocumentType)" Label="@LanguageLocale.dto_GuestDocument_DocumentType"
|
||||
Required ReadOnly="@ReadOnlyDocId">
|
||||
@foreach (string docType in dataListService.GetDataListByName(GuestConsts.DataList_DocumentTypes))
|
||||
{
|
||||
<MudSelectItem Value="docType">
|
||||
@dataListService.GetLocalizedValue(GuestConsts.DataList_DocumentTypes, docType)
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
<MudTextField @bind-Value="Model.DocumentNum" For="@(() => Model.DocumentNum)" Label="@LanguageLocale.dto_GuestDocument_DocumentNum"
|
||||
Required ReadOnly="@ReadOnlyDocId" />
|
||||
</MudStack>
|
||||
|
||||
<MudStack Row style="@FieldMarginY">
|
||||
<MudDatePicker @bind-Date="Model.IssueDate" For="@(() => Model.IssueDate)" Label="@LanguageLocale.dto_GuestDocument_IssueDate"
|
||||
Clearable OpenTo="OpenTo.Year" Editable />
|
||||
|
||||
<MudTextField @bind-Value="Model.SupportNum" For="@(() => Model.SupportNum)" Label="@LanguageLocale.dto_GuestDocument_SupportNum"
|
||||
Required="@isSuportNumberRequired" Mask="@(new PatternMask("aaa000000"))"
|
||||
OnBlur="@(() => Model.SupportNum = Model.SupportNum?.ToUpper())" />
|
||||
</MudStack>
|
||||
|
||||
<MudAutocomplete T="string" @bind-Value="Model.Nationality" For="@(() => Model.Nationality)" Label="@LanguageLocale.dto_GuestDocument_Nationality"
|
||||
SearchFunc="@SearchCountryCodes" ToStringFunc="@(e=> string.IsNullOrEmpty(e) ? "" : @dataListService.GetLocalizedValue(GuestConsts.DataList_CountryCodes, e))"
|
||||
SelectValueOnTab="true" AdornmentIcon="@Icons.Material.Filled.Search"
|
||||
style="@FieldMarginY" />
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudPaper Class="pa-4" Elevation="3" Height="100%">
|
||||
<MudText Typo="Typo.subtitle1" Align="Align.Center">@LanguageLocale.control_GuestDocForm_sectionGuest</MudText>
|
||||
<MudDivider DividerType="DividerType.Middle" Class="mb-4" />
|
||||
|
||||
<MudTextField @bind-Value="Model.Name" For="@(() => Model.Name)"
|
||||
Label="@LanguageLocale.dto_GuestDocument_Name"
|
||||
OnBlur="@(() => Model.Name = Model.Name?.ToUpper())" />
|
||||
<MudTextField @bind-Value="Model.Surname" For="@(() => Model.Surname)"
|
||||
Label="@LanguageLocale.dto_GuestDocument_Surname"
|
||||
OnBlur="@(() => Model.Surname = Model.Surname?.ToUpper())" />
|
||||
<MudTextField @bind-Value="Model.Surname2" For="@(() => Model.Surname2)"
|
||||
Label="@LanguageLocale.dto_GuestDocument_Surname2"
|
||||
OnBlur="@(() => Model.Surname2 = Model.Surname2?.ToUpper())" />
|
||||
|
||||
<MudStack Row style="@FieldMarginY">
|
||||
<MudDatePicker @bind-Date="Model.BirthDate" For="@(() => Model.BirthDate)" Label="@LanguageLocale.dto_GuestDocument_BirthDate"
|
||||
Clearable OpenTo="OpenTo.Year" Editable />
|
||||
|
||||
<MudSelect @bind-Value="Model.Gender" For="@(() => Model.Gender)" Label="@LanguageLocale.dto_GuestDocument_Gender">
|
||||
@foreach (string gender in dataListService.GetDataListByName(GuestConsts.DataList_GenderOptions))
|
||||
{
|
||||
<MudSelectItem Value="gender">
|
||||
@dataListService.GetLocalizedValue(GuestConsts.DataList_GenderOptions, gender)
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
|
||||
<MudItem xs="12" md="6">
|
||||
<MudPaper Class="pa-4" Elevation="3" Height="100%">
|
||||
<MudText Typo="Typo.subtitle1" Align="Align.Center">@LanguageLocale.control_GuestDocForm_sectionContact</MudText>
|
||||
<MudDivider DividerType="DividerType.Middle" Class="mb-4" />
|
||||
|
||||
<MudStack Row>
|
||||
<MudTextField @bind-Value="Model.PhoneNumber" For="@(() => Model.PhoneNumber)"
|
||||
Label="@LanguageLocale.dto_GuestDocument_PhoneNumber"
|
||||
InputType="InputType.Telephone" />
|
||||
<MudTextField @bind-Value="Model.EmailAddress" For="@(() => Model.EmailAddress)"
|
||||
Label="@LanguageLocale.dto_GuestDocument_EmailAddress"
|
||||
InputType="InputType.Email" />
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
|
||||
<MudItem xs="12" md="6">
|
||||
<MudPaper Class="pa-4" Elevation="3" Height="100%">
|
||||
<MudText Typo="Typo.subtitle1" Align="Align.Center">@LanguageLocale.control_GuestDocForm_sectionAddress</MudText>
|
||||
<MudDivider DividerType="DividerType.Middle" Class="mb-4" />
|
||||
|
||||
@if (!ReadOnly)
|
||||
{
|
||||
<MudButton OnClick="BtnOpenAddressSearchDialog" Variant="Variant.Outlined" FullWidth="true" Class="mb-2">
|
||||
@LanguageLocale.control_GuestDocForm_btnSearchAddress
|
||||
</MudButton>
|
||||
}
|
||||
|
||||
<MudTextField @bind-Value="Model.Address" For="@(() => Model.Address)"
|
||||
Label="@LanguageLocale.general_address_address" ReadOnly="@ReadOnlyAddress" />
|
||||
<MudStack Row style="@FieldMarginY">
|
||||
<MudTextField @bind-Value="Model.AddressCity" For="@(() => Model.AddressCity)"
|
||||
Label="@LanguageLocale.general_address_city" ReadOnly="@ReadOnlyAddress" />
|
||||
<MudTextField @bind-Value="Model.AddressProvince" For="@(() => Model.AddressProvince)"
|
||||
Label="@LanguageLocale.general_address_province" ReadOnly="@ReadOnlyAddress" />
|
||||
<MudTextField @bind-Value="Model.AddressState" For="@(() => Model.AddressState)"
|
||||
Label="@LanguageLocale.general_address_state" ReadOnly="@ReadOnlyAddress" />
|
||||
</MudStack>
|
||||
<MudStack Row style="@FieldMarginY">
|
||||
<MudAutocomplete T="string" @bind-Value="Model.AddressCountry" For="@(() => Model.AddressCountry)"
|
||||
Label="@LanguageLocale.general_address_country" ReadOnly="@ReadOnlyAddress"
|
||||
SearchFunc="@SearchCountryCodes" ToStringFunc="@(e=> string.IsNullOrEmpty(e) ? "" : @dataListService.GetLocalizedValue(GuestConsts.DataList_CountryCodes, e))"
|
||||
SelectValueOnTab="true" AdornmentIcon="@Icons.Material.Filled.Search" />
|
||||
|
||||
<MudTextField @bind-Value="Model.ZipCode" For="@(() => Model.ZipCode)"
|
||||
Label="@LanguageLocale.general_address_zipCode" ReadOnly="@ReadOnlyAddress" />
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
<MudText Class="mt-4">@CreateTimeString</MudText>
|
||||
</MudForm>
|
||||
|
||||
<AddressQueryDialog @ref="@AddressQueryDialog" />
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public GuestDocumentDTO Model { get; set; } = new();
|
||||
|
||||
[Parameter]
|
||||
public bool ReadOnly { get; set; } = false;
|
||||
|
||||
[Parameter]
|
||||
public bool ReadOnlyDocId { get; set; } = true;
|
||||
|
||||
|
||||
private MudForm _form = null!;
|
||||
AddressQueryDialog AddressQueryDialog { get; set; } = null!;
|
||||
DialogOptions AddressQueryDialogOptions = new()
|
||||
{
|
||||
MaxWidth = MaxWidth.Large,
|
||||
FullWidth = true,
|
||||
};
|
||||
private bool ReadOnlyAddress { get; set; } = true;
|
||||
|
||||
private const string FieldMarginY = "margin-block: 0.5em";
|
||||
|
||||
private Dictionary<string, string>? countryDict = null;
|
||||
|
||||
private bool isSuportNumberRequired { get => Model?.Nationality == GuestConsts.CountryCode_ESP; }
|
||||
private string CreateTimeString
|
||||
{
|
||||
get
|
||||
{
|
||||
List<string> textList = [];
|
||||
if (Model.CreateTime != null)
|
||||
{
|
||||
textList.Add($"Created at: {Model.CreateTime.Value.ToString()}");
|
||||
}
|
||||
if (Model.UpdateTime != null)
|
||||
{
|
||||
textList.Add($"Last Update Time: {Model.UpdateTime.Value.ToString()}");
|
||||
}
|
||||
return string.Join("; ", textList);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> ValidateForm()
|
||||
{
|
||||
await _form.ValidateAsync();
|
||||
return _form.IsValid;
|
||||
}
|
||||
|
||||
private async Task<IEnumerable<string>> SearchCountryCodes(string value, CancellationToken token)
|
||||
{
|
||||
// if text is null or empty, show complete list
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
return new string[0];
|
||||
}
|
||||
|
||||
if (countryDict is null || countryDict.Count == 0)
|
||||
{
|
||||
var countryCodeSet = dataListService.GetDataListByName(GuestConsts.DataList_CountryCodes);
|
||||
countryDict = new(countryCodeSet.Count);
|
||||
|
||||
//Init dict.
|
||||
foreach(string code in dataListService.GetDataListByName(GuestConsts.DataList_CountryCodes))
|
||||
{
|
||||
countryDict.Add(code, dataListService.GetLocalizedValue(GuestConsts.DataList_CountryCodes, code));
|
||||
}
|
||||
}
|
||||
|
||||
return countryDict
|
||||
.Where(x => x.Value.Contains(value, StringComparison.InvariantCultureIgnoreCase))
|
||||
.Select(x => x.Key);
|
||||
}
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
private async Task BtnOpenAddressSearchDialog()
|
||||
{
|
||||
var reference = await AddressQueryDialog.ShowAsync(options: AddressQueryDialogOptions);
|
||||
|
||||
DialogResult? result = await reference.Result;
|
||||
|
||||
if (result is null || result.Canceled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AddressResultDTO? resultData = await reference.GetReturnValueAsync<AddressResultDTO>();
|
||||
if (resultData is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//Update Address info.
|
||||
Model.Address = $"{resultData.AddressRoad}, {resultData.HouseNumber}";
|
||||
Model.AddressCity = resultData.AddressCity;
|
||||
Model.AddressProvince = resultData.AddressProvince;
|
||||
Model.AddressState = resultData.AddressState;
|
||||
Model.ZipCode = resultData.ZipCode;
|
||||
|
||||
//Set country by address code.
|
||||
Model.AddressCountry = resultData.AddressCountryCode;
|
||||
|
||||
//Address is editable after searching (if the form is editable).
|
||||
ReadOnlyAddress = ReadOnly;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
@using Somnia.GuestLog.Models.DTOs
|
||||
@using Somnia.GuestLog.Services
|
||||
|
||||
@inject IDataListService dataListService;
|
||||
|
||||
<MudForm Model="@Filter" IsTouchedChanged="@(() => FilterChanged.InvokeAsync(Filter))">
|
||||
<MudStack Row Breakpoint="Breakpoint.LgAndDown" StretchItems="StretchItems.All">
|
||||
<MudStack Row style="margin-block: 0.2em;">
|
||||
<MudSelect @bind-Value="Filter.DocumentType" For="@(() => Filter.DocumentType)"
|
||||
Label="@LanguageLocale.dto_GuestDocument_DocumentType" FullWidth Clearable>
|
||||
@foreach (string docType in dataListService.GetDataListByName(GuestConsts.DataList_DocumentTypes))
|
||||
{
|
||||
<MudSelectItem Value="docType">
|
||||
@dataListService.GetLocalizedValue(GuestConsts.DataList_DocumentTypes, docType)
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
<MudTextField @bind-Value="Filter.DocumentNumber" For="@(() => Filter.DocumentNumber)"
|
||||
Label="@LanguageLocale.dto_GuestDocument_DocumentNum" FullWidth Clearable />
|
||||
</MudStack>
|
||||
<MudStack Row style="margin-block: 0.2em;">
|
||||
<MudTextField @bind-Value="Filter.Name" For="@(() => Filter.Name)"
|
||||
Label="@LanguageLocale.dto_GuestDocument_Name" HelperText="@LanguageLocale.general_wildcardHelperText"
|
||||
HelperTextOnFocus="true" FullWidth Clearable OnBlur="@(() => Filter.Name = Filter.Name?.ToUpper())" />
|
||||
<MudTextField @bind-Value="Filter.Surname" For="@(() => Filter.Surname)"
|
||||
Label="@LanguageLocale.dto_GuestDocument_Surname"
|
||||
HelperText="@LanguageLocale.general_wildcardHelperText" HelperTextOnFocus="true" FullWidth Clearable
|
||||
OnBlur="@(() => Filter.Surname = Filter.Surname?.ToUpper())" />
|
||||
</MudStack>
|
||||
</MudStack>
|
||||
</MudForm>
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public GuestDocFilterDTO Filter { get; set; } = new();
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<GuestDocFilterDTO> FilterChanged { get; set; }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
@using System.ComponentModel
|
||||
@using Somnia.GuestLog.Models.DTOs
|
||||
@using Somnia.GuestLog.Services
|
||||
|
||||
@inject IDataListService dataListService;
|
||||
|
||||
<MudForm Model="@Filter" IsTouchedChanged="@(() => FilterChanged.InvokeAsync(Filter))">
|
||||
<MudStack Row Breakpoint="Breakpoint.LgAndDown" StretchItems="StretchItems.All">
|
||||
<MudStack Row style="margin-block: 0.2em;">
|
||||
<MudDatePicker @bind-Date="Filter.DateInStart" For="@(() => Filter.DateInStart)"
|
||||
Label="@LanguageLocale.general_dateStart" OpenTo="OpenTo.Date" Editable Required="@DateRequired" />
|
||||
<MudDatePicker @bind-Date="Filter.DateInEnd" For="@(() => Filter.DateInEnd)"
|
||||
Label="@LanguageLocale.general_dateEnd" OpenTo="OpenTo.Date" Editable Required="@DateRequired" />
|
||||
</MudStack>
|
||||
|
||||
<MudStack Row style="margin-block: 0.2em;">
|
||||
<MudTextField @bind-Value="Filter.RoomNumber" For="@(() => Filter.RoomNumber)"
|
||||
Label="@LanguageLocale.dto_StayEntry_RoomNumber" FullWidth Clearable />
|
||||
<MudSelect @bind-Value="Filter.PaymentMethod" For="@(() => Filter.PaymentMethod)"
|
||||
Label="@LanguageLocale.dto_StayEntry_PaymentMethod" FullWidth Clearable>
|
||||
@foreach (string paymentType in
|
||||
dataListService.GetDataListByName(GuestConsts.DataList_PaymentMethods))
|
||||
{
|
||||
<MudSelectItem Value="paymentType">
|
||||
@dataListService.GetLocalizedValue(GuestConsts.DataList_PaymentMethods, paymentType)
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</MudStack>
|
||||
</MudStack>
|
||||
</MudForm>
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter, Bindable(true)]
|
||||
public StayEntryFilterDTO Filter { get; set; } = new();
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<StayEntryFilterDTO> FilterChanged { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public bool DateRequired { get; set; } = true;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,270 @@
|
||||
@using System.Diagnostics
|
||||
@using FluentValidation;
|
||||
@using Somnia.GuestLog.Models.DTOs;
|
||||
@using Somnia.GuestLog.Services;
|
||||
@using Somnia.GuestLog.Validators;
|
||||
|
||||
@inject IDataListService dataListService;
|
||||
@inject IValidator<StayEntryDTO> stayValidator;
|
||||
@inject IDialogService dialogService;
|
||||
@inject IUserMessageService userMessage
|
||||
|
||||
|
||||
<MudForm @ref="@_form" Model="@Model" Validation="@((stayValidator as StayEntryDTOValidator)!.ValidateValue)"
|
||||
ReadOnly="@ReadOnly">
|
||||
<MudGrid>
|
||||
<MudItem xs="12" xl=6>
|
||||
<MudPaper Class="pa-4" Elevation="3" Height="100%">
|
||||
<MudText Typo="Typo.subtitle1" Align="Align.Center">
|
||||
@LanguageLocale.control_StayEntryForm_sectionDetails
|
||||
</MudText>
|
||||
<MudDivider DividerType="DividerType.Middle" Class="mb-4" />
|
||||
|
||||
<MudStack Row style="@FieldMarginY">
|
||||
<MudDatePicker @ref="_datePickerDateIn" @bind-Date="Model.DateIn" For="@(() => Model.DateIn)"
|
||||
Label="@LanguageLocale.dto_StayEntry_DateIn" Clearable OpenTo="OpenTo.Date" Editable
|
||||
AutoClose="true" />
|
||||
<MudTimePicker Time="Model.DateIn?.TimeOfDay" Label=" " Editable
|
||||
TimeChanged="@((newVal) => Model.DateIn = GetDateTimeFromDateAndTime(Model.DateIn, newVal))" />
|
||||
<MudDatePicker @ref="_datePickerDateOut" @bind-Date="Model.DateOut" For="@(() => Model.DateOut)"
|
||||
Label="@LanguageLocale.dto_StayEntry_DateOut" Clearable OpenTo="OpenTo.Date" Editable
|
||||
AutoClose="true" />
|
||||
<MudTimePicker Time="Model.DateOut?.TimeOfDay" Label=" " Editable
|
||||
TimeChanged="@((newVal) => Model.DateOut = GetDateTimeFromDateAndTime(Model.DateOut, newVal))" />
|
||||
</MudStack>
|
||||
<MudStack Row style="@FieldMarginY">
|
||||
<MudTextField @bind-Value="Model.RoomCount" For="@(() => Model.RoomCount)"
|
||||
Label="@LanguageLocale.dto_StayEntry_RoomCount" InputType="InputType.Number" FullWidth />
|
||||
<MudTextField @bind-Value="Model.RoomNumber" For="@(() => Model.RoomNumber)"
|
||||
Label="@LanguageLocale.dto_StayEntry_RoomNumber" FullWidth />
|
||||
|
||||
<MudSelect @bind-Value="Model.PaymentMethod" For="@(() => Model.PaymentMethod)"
|
||||
Label="@LanguageLocale.dto_StayEntry_PaymentMethod" FullWidth>
|
||||
@foreach (string payment in PaymentMethodSet)
|
||||
{
|
||||
<MudSelectItem Value="payment">
|
||||
@dataListService.GetLocalizedValue(GuestConsts.DataList_PaymentMethods, payment)
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
<MudItem xs="12" xl=6>
|
||||
<MudPaper Class="pa-4" Elevation="3" Height="100%" Width="100%">
|
||||
<MudText Typo="Typo.subtitle1" Align="Align.Center">
|
||||
@LanguageLocale.control_StayEntryForm_sectionGuests
|
||||
</MudText>
|
||||
<MudDivider DividerType="DividerType.Middle" Class="mb-4" />
|
||||
|
||||
@if (!ReadOnly)
|
||||
{
|
||||
<MudStack Row style="@FieldMarginY">
|
||||
<MudButton OnClick="BtnAddGuest" StartIcon="@Icons.Material.Filled.Add">
|
||||
@LanguageLocale.control_StayEntryForm_btnAddGuest
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
}
|
||||
|
||||
<MudTable Items="@Model.GuestDocuments" Hover="true">
|
||||
<HeaderContent>
|
||||
<MudTh>@LanguageLocale.dto_GuestDocument_DocumentType</MudTh>
|
||||
<MudTh>@LanguageLocale.dto_GuestDocument_DocumentNum</MudTh>
|
||||
<MudTh>@LanguageLocale.dto_GuestDocument_Name</MudTh>
|
||||
<MudTh>@LanguageLocale.dto_GuestDocument_Surname</MudTh>
|
||||
<MudTh>@LanguageLocale.dto_GuestDocument_Surname2</MudTh>
|
||||
<MudTh>@LanguageLocale.general_actions</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="@LanguageLocale.dto_GuestDocument_DocumentType">
|
||||
@context.DocumentType
|
||||
</MudTd>
|
||||
<MudTd DataLabel="@LanguageLocale.dto_GuestDocument_DocumentNum">
|
||||
@context.DocumentNum
|
||||
</MudTd>
|
||||
<MudTd DataLabel="@LanguageLocale.dto_GuestDocument_Name">
|
||||
@context.Name
|
||||
</MudTd>
|
||||
<MudTd DataLabel="@LanguageLocale.dto_GuestDocument_Surname" HideSmall="true">
|
||||
@context.Surname
|
||||
</MudTd>
|
||||
<MudTd DataLabel="@LanguageLocale.dto_GuestDocument_Surname2" HideSmall="true">
|
||||
@context.Surname2
|
||||
</MudTd>
|
||||
@if (!ReadOnly)
|
||||
{
|
||||
<MudTd DataLabel="@LanguageLocale.general_actions">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete"
|
||||
OnClick="@(() => BtnDeleteGuest(context.Id!.Value, context.Version!.Value))" />
|
||||
</MudTd>
|
||||
}
|
||||
@if (ReadOnly)
|
||||
{
|
||||
<MudTd DataLabel="@LanguageLocale.general_actions">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Info"
|
||||
OnClick="@(() => BtnViewGuestDetails(context))" />
|
||||
</MudTd>
|
||||
}
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
</MudForm>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public StayEntryDTO Model { private get; set; } = new();
|
||||
|
||||
[Parameter, EditorRequired]
|
||||
public FormMode FormMode { get; set; }
|
||||
|
||||
|
||||
private bool ReadOnly => FormMode == FormMode.ReadOnly;
|
||||
|
||||
|
||||
private MudForm _form = null!;
|
||||
private MudDatePicker _datePickerDateIn = null!;
|
||||
private MudDatePicker _datePickerDateOut = null!;
|
||||
|
||||
private const string FieldMarginY = "margin-block: 0.5em";
|
||||
private IEnumerable<string> PaymentMethodSet
|
||||
{
|
||||
get
|
||||
{
|
||||
if (field is null)
|
||||
{
|
||||
field = dataListService.GetDataListByName(GuestConsts.DataList_PaymentMethods);
|
||||
}
|
||||
return field;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
//Initialize values when not ReadOnly.
|
||||
if (FormMode == FormMode.Create)
|
||||
{
|
||||
Model.DateIn = DateTime.Now;
|
||||
|
||||
DateTime dateOut = DateTime.Today.AddDays(1);
|
||||
Model.DateOut = new(
|
||||
year: dateOut.Year, month: dateOut.Month, day: dateOut.Day,
|
||||
hour: 12, minute: 0, second: 0
|
||||
);
|
||||
|
||||
//Init Guest List
|
||||
Model.GuestDocuments = [];
|
||||
}
|
||||
}
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public async Task<bool> ValidateForm()
|
||||
{
|
||||
await _form.ValidateAsync();
|
||||
|
||||
if (Model.GuestDocuments is null || Model.GuestDocuments.Count == 0)
|
||||
{
|
||||
userMessage.ShowMessage("At least 1 guest is required!", MessageKind.Warning);
|
||||
return false;
|
||||
}
|
||||
|
||||
return _form.IsValid;
|
||||
}
|
||||
|
||||
public StayEntryDTO GetModel()
|
||||
{
|
||||
return Model;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private static DateTime? GetDateTimeFromDateAndTime(DateTime? date, TimeSpan? time)
|
||||
{
|
||||
DateOnly? dateOnly = date is not null ? DateOnly.FromDateTime(date.Value) : null;
|
||||
TimeOnly? timeOnly = time is not null ? TimeOnly.FromTimeSpan(time.Value) : null;
|
||||
|
||||
if (dateOnly is not null && timeOnly is not null)
|
||||
{
|
||||
return new DateTime(dateOnly.Value, timeOnly.Value);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
private async Task BtnAddGuest()
|
||||
{
|
||||
Debug.Assert(Model.GuestDocuments != null);
|
||||
|
||||
DialogOptions dialogOptions = new()
|
||||
{
|
||||
MaxWidth = MaxWidth.Medium,
|
||||
FullWidth = true,
|
||||
BackdropClick = false,
|
||||
CloseOnEscapeKey = true,
|
||||
};
|
||||
|
||||
var dialog = await dialogService.ShowAsync<GuestDocumentSearchDialog>(title: "", options: dialogOptions);
|
||||
DialogResult? result = await dialog.Result;
|
||||
|
||||
if (result is null || result.Canceled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GuestDocumentDTO? resultData = await dialog.GetReturnValueAsync<GuestDocumentDTO>();
|
||||
|
||||
if (resultData is null)
|
||||
{
|
||||
userMessage.ShowMessage("Error! No Guest Document selected!", MessageKind.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
//Check if this guest is already added.
|
||||
if (Model.GuestDocuments.Count > 0)
|
||||
{
|
||||
bool alreadyAdded = Model.GuestDocuments.Any(e => e.Id == resultData.Id);
|
||||
if (alreadyAdded)
|
||||
{
|
||||
userMessage.ShowMessage("GuestDocument already added!", MessageKind.Warning);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Model.GuestDocuments.Add(resultData);
|
||||
}
|
||||
|
||||
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.Id == guestDocId && e.Version == version))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
||||
private async Task BtnViewGuestDetails(GuestDocumentDTO item)
|
||||
{
|
||||
var parameters =
|
||||
new DialogParameters<GuestDocDetailsDialog> { { x => x.DocumentDTO, item } };
|
||||
var options = new DialogOptions()
|
||||
{
|
||||
FullScreen = true,
|
||||
CloseButton = true,
|
||||
CloseOnEscapeKey = true,
|
||||
};
|
||||
|
||||
await dialogService.ShowAsync<GuestDocDetailsDialog>("GuestDoc Details", parameters, options);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
<MudAppBar Elevation="1" Style="opacity: 100%;">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start"
|
||||