SHA256
Compare commits
34
Commits
26f77bb8fd
...
StayExport
| 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"
|
||||
OnClick="@((e) => DrawerToggle())" />
|
||||
<MudText Typo="Typo.h5" Class="ml-3">Somnia GuestLog</MudText>
|
||||
<MudText Typo="Typo.h5" Class="ml-3">Somnia.GuestLog</MudText>
|
||||
<MudSpacer />
|
||||
<MudToggleIconButton Class="ml-auto" Icon="@Icons.Material.Outlined.LightMode"
|
||||
ToggledIcon="@Icons.Material.Outlined.DarkMode" ToggledColor="Color.Primary" Color="Color.Primary"
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
|
||||
<MudNavMenu>
|
||||
<MudNavMenu>
|
||||
<MudNavLink Href="" Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Home">Home</MudNavLink>
|
||||
|
||||
@*
|
||||
<MudNavLink Href="counter" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Add">Counter</MudNavLink>
|
||||
|
||||
<MudNavLink Href="weather" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.List">Weather</MudNavLink>
|
||||
*@
|
||||
|
||||
<MudNavLink Href="@GuestConsts.Page_GuestDocs_List" Match="NavLinkMatch.Prefix"
|
||||
Icon="@Icons.Material.Filled.DocumentScanner">
|
||||
@LanguageLocale.navMenu_GuestDocumentList
|
||||
</MudNavLink>
|
||||
<MudNavLink Href="@GuestConsts.Page_StayEntry_List" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Book">
|
||||
@LanguageLocale.navMenu_StayEntryList
|
||||
</MudNavLink>
|
||||
<MudNavLink Href="@GuestConsts.Page_StayExport_List" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.ImportExport">
|
||||
@LanguageLocale.navMenu_StayExport
|
||||
</MudNavLink>
|
||||
</MudNavMenu>
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
@page "/debug/addrSearch"
|
||||
|
||||
@using Somnia.GuestLog.Models.DTOs;
|
||||
@using Somnia.GuestLog.Services;
|
||||
@using Somnia.GuestLog.Services.AddressQuery;
|
||||
|
||||
@inject ILogger<AddressQuery> logger;
|
||||
@inject IAddressQueryFactory addressQueryFactory;
|
||||
@inject IUserMessageService userMessage
|
||||
@inject IDialogService DialogService
|
||||
|
||||
<PageTitle>DEBUG - Address Query</PageTitle>
|
||||
|
||||
<MudText Typo="Typo.h3" GutterBottom="true" Class="mt-2">Address Search</MudText>
|
||||
|
||||
<MudPaper Class="ma-2 pa-4">
|
||||
<MudStack Row>
|
||||
<MudTextField @ref="txtSearch" @bind-Value="SearchText" Label="Search address" Required />
|
||||
<MudButton Color="Color.Primary" Variant="Variant.Filled" @onclick="btnSearchAddress" Class="mt-2">Search
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
|
||||
<MudPaper class="mt-2 pa-4">
|
||||
@if (addressResults.Count == 0)
|
||||
{
|
||||
<MudText Typo="Typo.body1">No results!</MudText>
|
||||
}
|
||||
@foreach (AddressResultDTO result in addressResults)
|
||||
{
|
||||
<MudItem>
|
||||
<MudStack>
|
||||
<MudText>Address: @result.AddressRoad , @result.HouseNumber</MudText>
|
||||
<MudText>City: @result.AddressCity</MudText>
|
||||
<MudText>Province: @result.AddressProvince</MudText>
|
||||
<MudText>State: @result.AddressState</MudText>
|
||||
<MudText>Country: @result.AddressCountry</MudText>
|
||||
<MudText>ZipCode: @result.ZipCode</MudText>
|
||||
</MudStack>
|
||||
</MudItem>
|
||||
}
|
||||
</MudPaper>
|
||||
</MudPaper>
|
||||
|
||||
<MudDivider DividerType="DividerType.FullWidth" />
|
||||
|
||||
<MudPaper Class="ma-2 pa-4">
|
||||
<MudButton OnClick="btnOpenSearchDialog" Color="Color.Primary" Variant="Variant.Filled" FullWidth>
|
||||
Open Search Dialog
|
||||
</MudButton>
|
||||
|
||||
@if (dialogSelectedAddress is not null)
|
||||
{
|
||||
<MudPaper class="mt-2 pa-4">
|
||||
<MudText>Selected Address: </MudText>
|
||||
<MudStack>
|
||||
<MudText>Address: @dialogSelectedAddress.AddressRoad , @dialogSelectedAddress.HouseNumber</MudText>
|
||||
<MudText>City: @dialogSelectedAddress.AddressCity</MudText>
|
||||
<MudText>Province: @dialogSelectedAddress.AddressProvince</MudText>
|
||||
<MudText>State: @dialogSelectedAddress.AddressState</MudText>
|
||||
<MudText>Country: @dialogSelectedAddress.AddressCountry</MudText>
|
||||
<MudText>ZipCode: @dialogSelectedAddress.ZipCode</MudText>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
}
|
||||
</MudPaper>
|
||||
|
||||
@code {
|
||||
|
||||
public string SearchText { get; set; } = "";
|
||||
private List<AddressResultDTO> addressResults = [];
|
||||
|
||||
private MudTextField<string> txtSearch = null!;
|
||||
|
||||
private AddressResultDTO? dialogSelectedAddress = null;
|
||||
|
||||
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 btnOpenSearchDialog()
|
||||
{
|
||||
DialogOptions options = new()
|
||||
{
|
||||
MaxWidth = MaxWidth.Large,
|
||||
FullWidth= true,
|
||||
};
|
||||
|
||||
var dialog = await DialogService.ShowAsync<AddressQueryDialog>("Search Address", options);
|
||||
DialogResult? result = await dialog.Result;
|
||||
|
||||
if (result is not null && !result.Canceled)
|
||||
{
|
||||
AddressResultDTO? resultData = await dialog.GetReturnValueAsync<AddressResultDTO>();
|
||||
|
||||
dialogSelectedAddress = resultData;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
@page "/debug/empty"
|
||||
|
||||
@using Somnia.GuestLog.Services
|
||||
|
||||
|
||||
@inject ILogger<Empty> logger;
|
||||
@inject IUserMessageService userMessage
|
||||
@inject IDialogService DialogService
|
||||
|
||||
<PageTitle>DEBUG - Empty</PageTitle>
|
||||
|
||||
<MudText Typo="Typo.h3" GutterBottom="true" Class="mt-2">Empty Page for Debug</MudText>
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
@attribute [Route($"{GuestConsts.Page_GuestDocs_Detail}")]
|
||||
|
||||
@using Somnia.GuestLog.Models.DTOs;
|
||||
@using Somnia.GuestLog.Services;
|
||||
@using Microsoft.AspNetCore.WebUtilities;
|
||||
|
||||
@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">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>
|
||||
@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 (documentModel is not null)
|
||||
{
|
||||
<MudTabs Elevation="3" Rounded="true" ApplyEffectsToContainer="true" TabPanelsClass="pa-4" KeepPanelsAlive="true"
|
||||
Centered>
|
||||
|
||||
<MudTabPanel Text="Details" Icon="@Icons.Material.Filled.Info">
|
||||
<GuestDocForm @ref="_form" Model="documentModel" ReadOnly="true" />
|
||||
</MudTabPanel>
|
||||
|
||||
<MudTabPanel Text="Stays" ToolTip="Guest stays" OnClick="LoadTabGuestStays" Icon="@Icons.Material.Filled.Bed">
|
||||
<MudText>Total Stays: @(guestStaysLoading ? "Loading..." : guestStayList.Count())</MudText>
|
||||
<MudTable Items="@guestStayList" Hover="true" Loading="@guestStaysLoading" Class="mt-2" Elevation="2">
|
||||
<HeaderContent>
|
||||
<MudTh>@LanguageLocale.dto_StayEntry_DateIn</MudTh>
|
||||
<MudTh>@LanguageLocale.dto_StayEntry_DateOut</MudTh>
|
||||
<MudTh>@LanguageLocale.dto_StayEntry_RoomCount</MudTh>
|
||||
<MudTh>@LanguageLocale.dto_StayEntry_RoomNumber</MudTh>
|
||||
<MudTh>@LanguageLocale.general_actions</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="@LanguageLocale.dto_StayEntry_DateIn">
|
||||
@context.DateIn
|
||||
</MudTd>
|
||||
<MudTd DataLabel="@LanguageLocale.dto_StayEntry_DateOut">
|
||||
@context.DateOut
|
||||
</MudTd>
|
||||
<MudTd DataLabel="@LanguageLocale.dto_StayEntry_RoomCount">
|
||||
@context.RoomCount
|
||||
</MudTd>
|
||||
<MudTd DataLabel="@LanguageLocale.dto_StayEntry_RoomNumber">
|
||||
@context.RoomNumber
|
||||
</MudTd>
|
||||
<MudTd DataLabel="@LanguageLocale.general_actions">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Info" OnClick="@(() => BtnViewStayDetails(context))" />
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
<NoRecordsContent>
|
||||
<MudText>@LanguageLocale.general_noResults</MudText>
|
||||
</NoRecordsContent>
|
||||
<LoadingContent>
|
||||
<MudSkeleton Height="50px" Class="mx-4" />
|
||||
</LoadingContent>
|
||||
</MudTable>
|
||||
</MudTabPanel>
|
||||
|
||||
</MudTabs>
|
||||
}
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public long docId { get; set; }
|
||||
|
||||
GuestDocForm _form = null!;
|
||||
|
||||
GuestDocumentDTO? documentModel = null;
|
||||
|
||||
|
||||
IEnumerable<StayEntryDTO> guestStayList = [];
|
||||
bool guestStaysLoading = true;
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
//Get model from db.
|
||||
documentModel = await guestDocService.GetLastVersionDtoByIdAsync(docId);
|
||||
if (documentModel is null)
|
||||
{
|
||||
userMessage.ShowMessage($"GuestDocument not found with ID: '{docId}'", MessageKind.Error);
|
||||
Navigation.NotFound();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task LoadTabGuestStays()
|
||||
{
|
||||
//Only load when there is no data.
|
||||
if (guestStayList.Count() > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (documentModel is null || documentModel.Id is null || documentModel.Version is null)
|
||||
{
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
|
||||
guestStaysLoading = true;
|
||||
guestStayList = await stayService.GetStaysWithGuest(documentModel.Id.Value);
|
||||
guestStaysLoading = false;
|
||||
}
|
||||
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
private void BtnEdit()
|
||||
{
|
||||
userMessage.ShowMessage("Not implemented yet!", MessageKind.Info);
|
||||
}
|
||||
|
||||
private void BtnReturn()
|
||||
{
|
||||
Navigation.NavigateTo(GuestConsts.Page_GuestDocs_List);
|
||||
}
|
||||
|
||||
|
||||
private void BtnViewStayDetails(StayEntryDTO item)
|
||||
{
|
||||
string itemId = $"{item.Id ?? -1}";
|
||||
string uri = GuestConsts.Page_StayEntry_Detail.Replace(GuestConsts.Page_StayEntry_Detail_Param_Id, itemId);
|
||||
|
||||
string relativeUri = Navigation.ToBaseRelativePath(Navigation.Uri);
|
||||
uri = QueryHelpers.AddQueryString(uri, [
|
||||
new KeyValuePair<string, string?>(GuestConsts.QueryParam_ReturnUrl, relativeUri)
|
||||
]);
|
||||
Navigation.NavigateTo(uri);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
@attribute [Route($"{GuestConsts.Page_GuestDocs_List}")]
|
||||
|
||||
@using Somnia.GuestLog.Models.DTOs;
|
||||
@using Somnia.GuestLog.Services;
|
||||
|
||||
@inject IGuestDocumentEntityService GuestDocService
|
||||
@inject NavigationManager Navigation
|
||||
@inject IUserMessageService userMessage
|
||||
@inject IDialogService DialogService
|
||||
@inject IDataListService dataListService;
|
||||
|
||||
|
||||
<PageTitle>Somnia - Guest Docs</PageTitle>
|
||||
|
||||
<MudStack Row="true" Class="my-4">
|
||||
<MudText Typo="Typo.h4" GutterBottom="true">@LanguageLocale.page_GuestDocList_pageTitle</MudText>
|
||||
<MudSpacer />
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Size="Size.Small"
|
||||
StartIcon="@Icons.Material.Filled.Search" OnClick="() => BtnSearchDataAsync()">
|
||||
@LanguageLocale.general_btnSearch
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Size="Size.Small" StartIcon="@Icons.Material.Filled.Add"
|
||||
OnClick="() => BtnNewGuest()">
|
||||
@LanguageLocale.page_GuestDocList_btnNewGuest
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
|
||||
<MudPaper Class="pa-4 my-4" Elevation="2" Height="100%">
|
||||
<GuestDocumentFilterForm @bind-Filter="docFilter" />
|
||||
</MudPaper>
|
||||
|
||||
<MudDataGrid @ref="_dataGrid" T="GuestDocumentDTO" Items="@guestDocList" Loading="@_dataLoading" ReadOnly="true"
|
||||
Hideable="true" ColumnsPanelReordering="true" Elevation="2">
|
||||
<ToolBarContent>
|
||||
<MudText Typo="Typo.subtitle1">@LanguageLocale.page_GuestDocList_documentList</MudText>
|
||||
<MudStack Class="ml-auto" Row="true" AlignItems="AlignItems.Center">
|
||||
<MudCheckBox @bind-Value="_showAllData" Label="@LanguageLocale.general_showAllElements"
|
||||
LabelPlacement="Placement.Start" />
|
||||
<MudButton StartIcon="@Icons.Material.Outlined.ViewColumn" Variant="Variant.Outlined" Size="Size.Small"
|
||||
OnClick="(args) => BtnConfigureColumnsClick(args)">
|
||||
@LanguageLocale.general_ConfigureColumns
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
</ToolBarContent>
|
||||
<Columns>
|
||||
<PropertyColumn Property="x => x.Id" Title="@LanguageLocale.dto_GuestDocument_Id" />
|
||||
<PropertyColumn Property="x => x.Version" Title="@LanguageLocale.dto_GuestDocument_Version" />
|
||||
<PropertyColumn Title="@LanguageLocale.dto_GuestDocument_DocumentType"
|
||||
Property="x => dataListService.GetLocalizedValue(GuestConsts.DataList_DocumentTypes, x.DocumentType)"
|
||||
Hideable="false" />
|
||||
<PropertyColumn Property="x => x.DocumentNum" Hideable="false"
|
||||
Title="@LanguageLocale.dto_GuestDocument_DocumentNum" />
|
||||
<PropertyColumn Property="x => x.Name" Title="@LanguageLocale.dto_GuestDocument_Name" />
|
||||
<PropertyColumn Property="x => x.Surname" Title="@LanguageLocale.dto_GuestDocument_Surname" />
|
||||
<PropertyColumn Property="x => x.Surname2" Title="@LanguageLocale.dto_GuestDocument_Surname2" />
|
||||
<PropertyColumn Title="@LanguageLocale.dto_GuestDocument_Nationality"
|
||||
Property="x => dataListService.GetLocalizedValue(GuestConsts.DataList_CountryCodes, x.Nationality)" />
|
||||
<PropertyColumn Property="x => x.UpdateTime" Title="@LanguageLocale.dto_GuestDocument_UpdateTime" />
|
||||
|
||||
<TemplateColumn CellClass="d-flex justify-between" Title="Options" StickyRight Hideable="false"
|
||||
ShowColumnOptions="false">
|
||||
<CellTemplate>
|
||||
<MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Info"
|
||||
OnClick="() => BtnViewDetails(context.Item)" />
|
||||
<MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Delete"
|
||||
OnClick="() => BtnDeleteItem(context.Item)" />
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
</Columns>
|
||||
<PagerContent>
|
||||
<MudDataGridPager T="GuestDocumentDTO" />
|
||||
</PagerContent>
|
||||
</MudDataGrid>
|
||||
|
||||
<ConfirmDeleteMsgBox @ref="_msgBoxConfirmDelete" />
|
||||
|
||||
|
||||
@code {
|
||||
private IEnumerable<GuestDocumentDTO> guestDocList = [];
|
||||
|
||||
private bool _dataLoading = true;
|
||||
private bool _showAllData = false;
|
||||
private const int resultLimit = 200;
|
||||
|
||||
private GuestDocFilterDTO docFilter = new GuestDocFilterDTO();
|
||||
|
||||
private MudDataGrid<GuestDocumentDTO> _dataGrid = null!;
|
||||
private ConfirmDeleteMsgBox _msgBoxConfirmDelete = null!;
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await LoadDataAsync(showMsg: false);
|
||||
}
|
||||
|
||||
#region Data Loading
|
||||
|
||||
private async Task LoadDataAsync(bool showMsg = true)
|
||||
{
|
||||
_dataLoading = true;
|
||||
|
||||
int dataLimit = _showAllData ? 0 : resultLimit;
|
||||
guestDocList = await GuestDocService.GetDtoListByFilterAsync(filter: docFilter, limit: dataLimit);
|
||||
|
||||
if (showMsg)
|
||||
{
|
||||
userMessage.ShowMessage("Data loaded from DB", MessageKind.Info);
|
||||
}
|
||||
_dataLoading = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
private async Task BtnSearchDataAsync()
|
||||
{
|
||||
docFilter.Name = docFilter.Name?.ToUpper();
|
||||
docFilter.Surname = docFilter.Surname?.ToUpper();
|
||||
|
||||
await LoadDataAsync();
|
||||
}
|
||||
|
||||
private async Task BtnConfigureColumnsClick(MouseEventArgs args)
|
||||
{
|
||||
_dataGrid.ShowColumnsPanel(args);
|
||||
}
|
||||
|
||||
|
||||
private async Task BtnViewDetails(GuestDocumentDTO item)
|
||||
{
|
||||
string strId = item.Id?.ToString() ?? throw new InvalidOperationException();
|
||||
|
||||
string uri = GuestConsts.Page_GuestDocs_Detail.Replace(GuestConsts.Page_GuestDocs_Detail_Param_DocId, strId);
|
||||
Navigation.NavigateTo(uri);
|
||||
}
|
||||
|
||||
private async Task BtnDeleteItem(GuestDocumentDTO item)
|
||||
{
|
||||
bool? confirmDelete = await _msgBoxConfirmDelete.MsgBox.ShowAsync();
|
||||
|
||||
if (confirmDelete is null || confirmDelete.Value == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Result deleteResult = await GuestDocService.DeleteDocumentAsync(item);
|
||||
if (!deleteResult.IsSuccess)
|
||||
{
|
||||
string errorMsg = $"Error deleting document {item.DocumentType}-{item.DocumentNum}";
|
||||
userMessage.ShowResultWithMessage(deleteResult, errorMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
userMessage.ShowMessage($"Document {item.DocumentType}-{item.DocumentNum} deleted!", MessageKind.Success);
|
||||
await LoadDataAsync(showMsg: false);
|
||||
}
|
||||
|
||||
private void BtnNewGuest()
|
||||
{
|
||||
Navigation.NavigateTo(GuestConsts.Page_GuestDocs_New);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
@attribute [Route($"{GuestConsts.Page_GuestDocs_New}")]
|
||||
|
||||
@using Somnia.GuestLog.Models.DTOs;
|
||||
@using Somnia.GuestLog.Services;
|
||||
@using Somnia.GuestLog.Validators;
|
||||
|
||||
@inject IUserMessageService userMessage
|
||||
@inject IDialogService DialogService
|
||||
@inject NavigationManager Navigation
|
||||
@inject IGuestDocumentEntityService guestDocService
|
||||
@inject IDataListService dataListService;
|
||||
|
||||
@inject FluentValidation.IValidator<GuestDocIdDTO> docIdValidator;
|
||||
|
||||
|
||||
<PageTitle>Somnia - Guest Docs - New</PageTitle>
|
||||
|
||||
<MudStack Row="true" Class="my-4">
|
||||
<MudText Typo="Typo.h4" GutterBottom="true">New Guest Document</MudText>
|
||||
<MudSpacer />
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Success" Size="Size.Small" StartIcon="@Icons.Material.Filled.Add"
|
||||
OnClick="() => BtnSaveNewGuest()">
|
||||
@LanguageLocale.general_btnCreate
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Default" Size="Size.Small"
|
||||
StartIcon="@Icons.Material.Filled.ArrowBack" OnClick="() => BtnReturn()">
|
||||
@LanguageLocale.general_btnReturn
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
|
||||
@if (currentPageMode == ePageMode.selectDocId || currentPageMode == ePageMode.alreadyExistDoc)
|
||||
{
|
||||
<MudPaper Class="pa-4" Elevation="3" Height="100%" Style="">
|
||||
<MudForm @ref="_docIdForm" Model="@currentDocId"
|
||||
Validation="@((docIdValidator as GuestDocIdDTOValidator)!.ValidateValue)">
|
||||
<MudStack Breakpoint="Breakpoint.Sm">
|
||||
<MudSelect @bind-Value="currentDocId.DocumentType" For="@(() => currentDocId.DocumentType)"
|
||||
Label="@LanguageLocale.dto_GuestDocument_DocumentType" Immediate="true" Required>
|
||||
|
||||
@foreach (string docType in dataListService.GetDataListByName(GuestConsts.DataList_DocumentTypes))
|
||||
{
|
||||
<MudSelectItem Value="docType">
|
||||
@dataListService.GetLocalizedValue(GuestConsts.DataList_DocumentTypes, docType)
|
||||
</MudSelectItem>
|
||||
}
|
||||
|
||||
</MudSelect>
|
||||
<MudTextField @bind-Value="currentDocId.DocumentNum" For="@(() => currentDocId.DocumentNum)"
|
||||
Label="@LanguageLocale.dto_GuestDocument_DocumentNum" Required
|
||||
OnBlur="@(() => currentDocId.DocumentNum = currentDocId.DocumentNum.ToUpper())" />
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Size="Size.Small"
|
||||
StartIcon="@Icons.Material.Filled.Search" OnClick="() => BtnCheckDocId()" Disabled="@loadingDocId">
|
||||
@LanguageLocale.general_btnSearch
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
</MudForm>
|
||||
|
||||
@if (currentPageMode == ePageMode.alreadyExistDoc)
|
||||
{
|
||||
<MudStack>
|
||||
<MudDivider Class="my-4" />
|
||||
<MudText Typo="Typo.body1" Style="text-align: center;">@LanguageLocale.page_GuestDocNew_msgAlreadyExists
|
||||
</MudText>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Size="Size.Small"
|
||||
StartIcon="@Icons.Material.Filled.Search" OnClick="() => BtnGoToDocument()">
|
||||
@LanguageLocale.page_GuestDocNew_btnGoExistingDoc
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
}
|
||||
</MudPaper>
|
||||
}
|
||||
|
||||
@if (currentPageMode == ePageMode.createNew)
|
||||
{
|
||||
<GuestDocForm @ref="_form" Model="newDocumentModel" />
|
||||
}
|
||||
|
||||
|
||||
@code {
|
||||
GuestDocForm _form = null!;
|
||||
MudForm _docIdForm = null!;
|
||||
|
||||
ePageMode currentPageMode = ePageMode.selectDocId;
|
||||
GuestDocIdDTO currentDocId = new() { DocumentNum = "", DocumentType = "" };
|
||||
long? alreadyExistDocId = null;
|
||||
GuestDocumentDTO newDocumentModel = new();
|
||||
|
||||
bool loadingDocId = false;
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
/// <summary>
|
||||
/// Check if given Document already exists or can be created.
|
||||
/// </summary>
|
||||
private async Task BtnCheckDocId()
|
||||
{
|
||||
await _docIdForm.ValidateAsync();
|
||||
if (!_docIdForm.IsValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
loadingDocId = true;
|
||||
GuestDocumentDTO? dto =
|
||||
await guestDocService.GetLastVersionDtoByDocumentAsync(currentDocId.DocumentType, currentDocId.DocumentNum);
|
||||
loadingDocId = false;
|
||||
|
||||
if (dto is null)
|
||||
{
|
||||
//Document don't exist -> Create it.
|
||||
currentPageMode = ePageMode.createNew;
|
||||
|
||||
//Update model with current DocId
|
||||
newDocumentModel.DocumentType = currentDocId.DocumentType;
|
||||
newDocumentModel.DocumentNum = currentDocId.DocumentNum;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//GuestDoc already exists!
|
||||
currentPageMode = ePageMode.alreadyExistDoc;
|
||||
alreadyExistDocId = dto.Id;
|
||||
}
|
||||
|
||||
private void BtnReturn()
|
||||
{
|
||||
Navigation.NavigateTo(GuestConsts.Page_GuestDocs_List);
|
||||
}
|
||||
|
||||
private async Task BtnSaveNewGuest()
|
||||
{
|
||||
bool isFormValid = await _form.ValidateForm();
|
||||
if (!isFormValid)
|
||||
{
|
||||
userMessage.ShowMessage("Invalid Form!", MessageKind.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
GuestDocumentDTO model = _form.Model;
|
||||
|
||||
//Show Loading dialog...
|
||||
var loadingDialog = await DialogService.ShowAsync<LoadingDialog>();
|
||||
|
||||
Result createResult = await guestDocService.CreateDocumentAsync(model);
|
||||
if (!createResult.IsSuccess)
|
||||
{
|
||||
string errorMsg = $"Error creating Document '{model.DocumentNum}'";
|
||||
userMessage.ShowResultWithMessage(createResult, errorMsg);
|
||||
loadingDialog.Close();
|
||||
return;
|
||||
}
|
||||
|
||||
userMessage.ShowMessage($"Document '{model.DocumentNum}' Created!", MessageKind.Success);
|
||||
Navigation.NavigateTo(GuestConsts.Page_GuestDocs_List);
|
||||
}
|
||||
|
||||
private void BtnGoToDocument()
|
||||
{
|
||||
if (currentPageMode != ePageMode.alreadyExistDoc || alreadyExistDocId is null)
|
||||
{
|
||||
userMessage.ShowMessage("Invalid operation!", MessageKind.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
string strId = alreadyExistDocId.Value.ToString();
|
||||
string uri = GuestConsts.Page_GuestDocs_Detail.Replace(GuestConsts.Page_GuestDocs_Detail_Param_DocId, strId);
|
||||
Navigation.NavigateTo(uri);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Models
|
||||
|
||||
enum ePageMode
|
||||
{
|
||||
selectDocId, alreadyExistDoc, createNew
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
@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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
@attribute [Route($"{GuestConsts.Page_StayEntry_List}")]
|
||||
|
||||
@using Somnia.GuestLog.Models.DTOs;
|
||||
@using Somnia.GuestLog.Services;
|
||||
|
||||
@inject IStayEntryEntityService StayEntryService
|
||||
@inject NavigationManager Navigation
|
||||
@inject IUserMessageService userMessage
|
||||
@inject IDialogService DialogService
|
||||
@inject IDataListService dataListService;
|
||||
|
||||
<PageTitle>Somnia - Stay Entries</PageTitle>
|
||||
|
||||
<MudStack Row="true" Class="my-4">
|
||||
<MudText Typo="Typo.h4" GutterBottom="true">@LanguageLocale.page_StayEntryList_pageTitle</MudText>
|
||||
<MudSpacer />
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Size="Size.Small"
|
||||
StartIcon="@Icons.Material.Filled.Search" OnClick="() => BtnSearchDataAsync()">
|
||||
@LanguageLocale.general_btnSearch
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Size="Size.Small" StartIcon="@Icons.Material.Filled.Add"
|
||||
OnClick="() => BtnNewStay()">
|
||||
@LanguageLocale.page_StayEntryList_btnNewStay
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
|
||||
<MudPaper Class="pa-4 my-4" Elevation="2" Height="100%">
|
||||
<StayEntryFilterForm @bind-Filter="stayFilter" />
|
||||
</MudPaper>
|
||||
|
||||
<MudDataGrid @ref="_dataGrid" T="StayEntryDTO" Items="@stayEntryList" Loading="@_dataLoading" ReadOnly="true"
|
||||
Elevation="2">
|
||||
<ToolBarContent>
|
||||
<MudText Typo="Typo.subtitle1">@LanguageLocale.page_StayEntryList_entryList</MudText>
|
||||
<MudStack Class="ml-auto" Row="true" AlignItems="AlignItems.Center">
|
||||
<MudCheckBox @bind-Value="_showAllData" Label="@LanguageLocale.general_showAllElements"
|
||||
LabelPlacement="Placement.Start" />
|
||||
</MudStack>
|
||||
</ToolBarContent>
|
||||
<Columns>
|
||||
<PropertyColumn Property="x => x.Id" Hideable="false" Title="@LanguageLocale.dto_StayEntry_Id" />
|
||||
<PropertyColumn Property="x => x.DateIn" Title="@LanguageLocale.dto_StayEntry_DateIn" />
|
||||
<PropertyColumn Property="x => x.DateOut" Title="@LanguageLocale.dto_StayEntry_DateOut" />
|
||||
<PropertyColumn Property="x => x.RoomNumber" Title="@LanguageLocale.dto_StayEntry_RoomNumber" />
|
||||
<PropertyColumn Title="@LanguageLocale.dto_StayEntry_PaymentMethod"
|
||||
Property="x => dataListService.GetLocalizedValue(GuestConsts.DataList_PaymentMethods, x.PaymentMethod)" />
|
||||
|
||||
<PropertyColumn Property="x => x.UpdateTime" Title="@LanguageLocale.dto_GuestDocument_UpdateTime" />
|
||||
|
||||
<TemplateColumn CellClass="d-flex justify-between" Title="Options" StickyRight Hideable="false"
|
||||
ShowColumnOptions="false">
|
||||
<CellTemplate>
|
||||
<MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Info"
|
||||
OnClick="() => BtnViewDetails(context.Item)" />
|
||||
<MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Delete"
|
||||
OnClick="() => BtnDeleteItem(context.Item)" />
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
</Columns>
|
||||
<PagerContent>
|
||||
<MudDataGridPager T="StayEntryDTO" />
|
||||
</PagerContent>
|
||||
</MudDataGrid>
|
||||
|
||||
<ConfirmDeleteMsgBox @ref="_confirmDeleteMsgBox" />
|
||||
|
||||
@code {
|
||||
|
||||
private bool _dataLoading = true;
|
||||
private bool _showAllData = false;
|
||||
private const int resultLimit = 200;
|
||||
|
||||
private StayEntryFilterDTO stayFilter = new StayEntryFilterDTO()
|
||||
{
|
||||
DateInStart = DateTime.Today.AddDays(-14),
|
||||
DateInEnd = DateTime.Today.AddDays(1),
|
||||
};
|
||||
|
||||
private IEnumerable<StayEntryDTO> stayEntryList = [];
|
||||
|
||||
private MudDataGrid<StayEntryDTO> _dataGrid = null!;
|
||||
private ConfirmDeleteMsgBox _confirmDeleteMsgBox = null!;
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await LoadDataAsync(showMsg: false);
|
||||
}
|
||||
|
||||
private async Task LoadDataAsync(bool showMsg = true)
|
||||
{
|
||||
_dataLoading = true;
|
||||
|
||||
int dataLimit = _showAllData ? 0 : resultLimit;
|
||||
stayEntryList = await StayEntryService.GetDtoListByFilterAsync(filter: stayFilter, limit: dataLimit);
|
||||
|
||||
if (showMsg)
|
||||
{
|
||||
userMessage.ShowMessage("Data loaded from DB", MessageKind.Info);
|
||||
}
|
||||
_dataLoading = false;
|
||||
}
|
||||
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
private async Task BtnSearchDataAsync()
|
||||
{
|
||||
await LoadDataAsync();
|
||||
}
|
||||
|
||||
private void BtnNewStay()
|
||||
{
|
||||
Navigation.NavigateTo(GuestConsts.Page_StayEntry_New);
|
||||
}
|
||||
|
||||
|
||||
private async Task BtnViewDetails(StayEntryDTO item)
|
||||
{
|
||||
string itemId = item.Id?.ToString() ?? throw new InvalidOperationException();
|
||||
string uri = GuestConsts.Page_StayEntry_Detail.Replace(GuestConsts.Page_StayEntry_Detail_Param_Id, itemId);
|
||||
Navigation.NavigateTo(uri);
|
||||
}
|
||||
|
||||
private async Task BtnDeleteItem(StayEntryDTO item)
|
||||
{
|
||||
bool? confirmDelete = await _confirmDeleteMsgBox.MsgBox.ShowAsync();
|
||||
|
||||
if (confirmDelete is null || confirmDelete.Value == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Result deleteResult = await StayEntryService.DeleteEntryAsync(item);
|
||||
if (!deleteResult.IsSuccess)
|
||||
{
|
||||
string errorMsg = $"Error deleting Stay {item.Id}";
|
||||
userMessage.ShowResultWithMessage(deleteResult, errorMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
userMessage.ShowMessage($"Stay {item.Id} deleted!", MessageKind.Success);
|
||||
await LoadDataAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
@attribute [Route($"{GuestConsts.Page_StayEntry_New}")]
|
||||
|
||||
@using Somnia.GuestLog.Models.DTOs;
|
||||
@using Somnia.GuestLog.Services;
|
||||
|
||||
|
||||
@inject IUserMessageService userMessage
|
||||
@inject IDialogService DialogService
|
||||
@inject NavigationManager Navigation
|
||||
@inject IStayEntryEntityService stayService
|
||||
@inject IDataListService dataListService;
|
||||
|
||||
<PageTitle>Somnia - Stay Entries - New</PageTitle>
|
||||
|
||||
<MudStack Row="true" Class="my-4">
|
||||
<MudText Typo="Typo.h4" GutterBottom="true">
|
||||
@LanguageLocale.page_StayEntryNew_pageTitle
|
||||
</MudText>
|
||||
<MudSpacer />
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Success" Size="Size.Small" StartIcon="@Icons.Material.Filled.Add"
|
||||
OnClick="() => BtnSaveStay()">
|
||||
@LanguageLocale.general_btnCreate
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Default" Size="Size.Small"
|
||||
StartIcon="@Icons.Material.Filled.ArrowBack" OnClick="() => BtnReturn()">
|
||||
@LanguageLocale.general_btnReturn
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
|
||||
<StayEntryForm @ref="_form" Model="@newStayModel" FormMode="FormMode.Create" />
|
||||
|
||||
@code {
|
||||
StayEntryForm _form = null!;
|
||||
|
||||
StayEntryDTO newStayModel = new();
|
||||
|
||||
|
||||
private void BtnReturn()
|
||||
{
|
||||
Navigation.NavigateTo(GuestConsts.Page_StayEntry_List);
|
||||
}
|
||||
|
||||
private async Task BtnSaveStay()
|
||||
{
|
||||
bool isFormValid = await _form.ValidateForm();
|
||||
if (!isFormValid)
|
||||
{
|
||||
userMessage.ShowMessage("Invalid Form!", MessageKind.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
var loadingDialog = await DialogService.ShowAsync<LoadingDialog>();
|
||||
|
||||
StayEntryDTO model = _form.GetModel();
|
||||
Result createResult = await stayService.CreateEntryAsync(model);
|
||||
if (!createResult.IsSuccess)
|
||||
{
|
||||
userMessage.ShowResultWithMessage(createResult, $"Error creating StayEntry");
|
||||
loadingDialog.Close();
|
||||
return;
|
||||
}
|
||||
|
||||
userMessage.ShowMessage($"StayEntry Created!", MessageKind.Success);
|
||||
Navigation.NavigateTo(GuestConsts.Page_StayEntry_List);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
@attribute [Route($"{GuestConsts.Page_StayExport_List}")]
|
||||
|
||||
@using System.Text.Json;
|
||||
@using Somnia.GuestLog.Models.DTOs;
|
||||
@using Somnia.GuestLog.Services;
|
||||
@using Somnia.GuestLog.Services.StayExport;
|
||||
|
||||
@inject IStayExportFileEntityService stayExportEntityService
|
||||
@inject NavigationManager Navigation
|
||||
@inject IUserMessageService userMessage
|
||||
@inject IDialogService DialogService
|
||||
@inject IDataListService dataListService;
|
||||
@inject ILocalizerService Localizer;
|
||||
|
||||
@inject IStayExportService ExportService;
|
||||
@inject IJSRuntime JS
|
||||
|
||||
|
||||
<PageTitle>Somnia - Stay Export Files</PageTitle>
|
||||
|
||||
<MudStack Row="true" Class="my-4">
|
||||
<MudText Typo="Typo.h4" GutterBottom="true">@LanguageLocale.page_StayExportList_pageTitle</MudText>
|
||||
<MudSpacer />
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Size="Size.Small"
|
||||
StartIcon="@Icons.Material.Filled.Search" OnClick="() => BtnSearchDataAsync()">
|
||||
@LanguageLocale.general_btnSearch
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Size="Size.Small" StartIcon="@Icons.Material.Filled.Add"
|
||||
OnClick="() => BtnNewExport()">
|
||||
@LanguageLocale.page_StayExportList_btnNewExport
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
|
||||
@* <MudPaper Class="pa-4 my-4" Elevation="2" Height="100%">
|
||||
FILTER
|
||||
</MudPaper> *@
|
||||
|
||||
<MudDataGrid @ref="_dataGrid" T="StayExportFileDTO" Items="@stayExportList" Loading="@_dataLoading" ReadOnly="true"
|
||||
Elevation="2">
|
||||
<ToolBarContent>
|
||||
<MudText Typo="Typo.subtitle1">@LanguageLocale.page_StayExportList_exportList</MudText>
|
||||
</ToolBarContent>
|
||||
<Columns>
|
||||
<PropertyColumn Property="x => x.Id" Hideable="false" Title="@LanguageLocale.dto_StayExportFile_Id" />
|
||||
<PropertyColumn Property="x => Localizer.GetEnumValue(x.ExportFormat)"
|
||||
Title="@LanguageLocale.dto_StayExportFile_ExportFormat" />
|
||||
<TemplateColumn Title="@LanguageLocale.dto_StayExportFile_ExportParams">
|
||||
<CellTemplate>
|
||||
<MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Info"
|
||||
OnClick="() => ShowExportParams(context.Item)" />
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
<PropertyColumn Property="x => Localizer.GetEnumValue(x.ExportResult)"
|
||||
Title="@LanguageLocale.dto_StayExportFile_ExportResult" />
|
||||
<PropertyColumn Property="x => x.ExportTime" Title="@LanguageLocale.dto_StayExportFile_ExportTime" />
|
||||
<TemplateColumn Title="@LanguageLocale.dto_StayExportFile_ExportDetails">
|
||||
<CellTemplate>
|
||||
<MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Info"
|
||||
OnClick="() => ShowExportDetails(context.Item)" />
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
|
||||
<TemplateColumn CellClass="d-flex justify-between" Title="Options" StickyRight Hideable="false"
|
||||
ShowColumnOptions="false">
|
||||
<CellTemplate>
|
||||
<MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Download"
|
||||
OnClick="() => BtnDownloadFile(context.Item)" />
|
||||
<MudIconButton Size="@Size.Small" Icon="@Icons.Material.Outlined.Delete"
|
||||
OnClick="() => BtnDeleteItem(context.Item)" />
|
||||
</CellTemplate>
|
||||
</TemplateColumn>
|
||||
</Columns>
|
||||
<PagerContent>
|
||||
<MudDataGridPager T="StayExportFileDTO" />
|
||||
</PagerContent>
|
||||
</MudDataGrid>
|
||||
|
||||
<ConfirmDeleteMsgBox @ref="_confirmDeleteMsgBox" />
|
||||
|
||||
@code {
|
||||
private bool _dataLoading = true;
|
||||
private const int resultLimit = 200;
|
||||
|
||||
private IEnumerable<StayExportFileDTO> stayExportList = [];
|
||||
|
||||
private MudDataGrid<StayExportFileDTO> _dataGrid = null!;
|
||||
private ConfirmDeleteMsgBox _confirmDeleteMsgBox = null!;
|
||||
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await LoadDataAsync(showMsg: false);
|
||||
}
|
||||
|
||||
private async Task LoadDataAsync(bool showMsg = true)
|
||||
{
|
||||
_dataLoading = true;
|
||||
|
||||
stayExportList = await stayExportEntityService.GetDtoListAsync(limit: resultLimit);
|
||||
|
||||
if (showMsg)
|
||||
{
|
||||
userMessage.ShowMessage("Data loaded from DB", MessageKind.Info);
|
||||
}
|
||||
_dataLoading = false;
|
||||
}
|
||||
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
private async Task BtnSearchDataAsync()
|
||||
{
|
||||
await LoadDataAsync();
|
||||
}
|
||||
|
||||
private void BtnNewExport()
|
||||
{
|
||||
Navigation.NavigateTo(GuestConsts.Page_StayExport_New);
|
||||
}
|
||||
|
||||
|
||||
private async Task ShowExportParams(StayExportFileDTO dto)
|
||||
{
|
||||
string jsonParams = JsonSerializer.Serialize(dto.ExportParams, options: new() { WriteIndented = true });
|
||||
|
||||
await DialogService.ShowMessageBoxAsync("Details", (MarkupString)$"<pre>{jsonParams}</pre>");
|
||||
}
|
||||
|
||||
private async Task ShowExportDetails(StayExportFileDTO dto)
|
||||
{
|
||||
if (string.IsNullOrEmpty(dto.ExportDetails))
|
||||
{
|
||||
userMessage.ShowMessage("This ExportFile doesn't have any export details", MessageKind.Info);
|
||||
return;
|
||||
}
|
||||
|
||||
using var jDoc = JsonDocument.Parse(dto.ExportDetails);
|
||||
string jsonDetails = JsonSerializer.Serialize(jDoc, new JsonSerializerOptions { WriteIndented = true });
|
||||
|
||||
await DialogService.ShowMessageBoxAsync("Details", (MarkupString)$"<pre>{jsonDetails}</pre>");
|
||||
}
|
||||
|
||||
private async Task BtnDownloadFile(StayExportFileDTO item)
|
||||
{
|
||||
if (item.ExportResult == Enums.Models.StayExportFileResult.NoData)
|
||||
{
|
||||
userMessage.ShowMessage("A Export without data can't be downloaded!", MessageKind.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(item.ExportedPath))
|
||||
{
|
||||
userMessage.ShowMessage("File can't be downloaded: no path found!", MessageKind.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
using Stream objectStream = new MemoryStream();
|
||||
Result loadResult = await ExportService.GetExportedFileAsync(item, objectStream);
|
||||
if (!loadResult.IsSuccess)
|
||||
{
|
||||
userMessage.ShowResultWithMessage(loadResult, "Exported File can't be downloaded");
|
||||
return;
|
||||
}
|
||||
|
||||
objectStream.Seek(0, SeekOrigin.Begin);
|
||||
|
||||
using var streamRef = new DotNetStreamReference(stream: objectStream);
|
||||
|
||||
var fileName = Path.GetFileName(item.ExportedPath);
|
||||
await JS.InvokeVoidAsync("downloadFileFromStream", fileName, streamRef);
|
||||
userMessage.ShowMessage("Exported File downloaded!", MessageKind.Success);
|
||||
}
|
||||
|
||||
private async Task BtnDeleteItem(StayExportFileDTO item)
|
||||
{
|
||||
bool? confirmDelete = await _confirmDeleteMsgBox.MsgBox.ShowAsync();
|
||||
|
||||
if (confirmDelete is null || confirmDelete.Value == false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Result deleteResult = await ExportService.DeleteExportedFileAsync(item);
|
||||
if (!deleteResult.IsSuccess)
|
||||
{
|
||||
string errorMsg = $"Error deleting Export file {item.Id}";
|
||||
userMessage.ShowResultWithMessage(deleteResult, errorMsg);
|
||||
return;
|
||||
}
|
||||
|
||||
userMessage.ShowMessage($"Export file {item.Id} deleted!", MessageKind.Success);
|
||||
await LoadDataAsync();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
@attribute [Route($"{GuestConsts.Page_StayExport_New}")]
|
||||
|
||||
@using FluentValidation;
|
||||
@using Somnia.GuestLog.Models.DTOs;
|
||||
@using Somnia.GuestLog.Enums.Models;
|
||||
@using Somnia.GuestLog.Services;
|
||||
@using Somnia.GuestLog.Validators;
|
||||
@using Somnia.GuestLog.Services.StayExport;
|
||||
|
||||
|
||||
@inject IUserMessageService userMessage
|
||||
@inject IDialogService DialogService
|
||||
@inject NavigationManager Navigation
|
||||
@inject IValidator<StayExportParamsDTO> ExportParamsValidator;
|
||||
@inject ILocalizerService Localizer;
|
||||
@inject IStayExportService ExportService;
|
||||
|
||||
@inject IJSRuntime JS
|
||||
|
||||
|
||||
<PageTitle>Somnia - Stay Export - New</PageTitle>
|
||||
|
||||
<MudStack Row="true" Class="my-4">
|
||||
<MudText Typo="Typo.h4" GutterBottom="true">
|
||||
@LanguageLocale.page_StayExportNew_pageTitle
|
||||
</MudText>
|
||||
<MudSpacer />
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Success" Size="Size.Small" StartIcon="@Icons.Material.Filled.Add"
|
||||
OnClick="() => BtnCreateExport()" Disabled="@_isExported">
|
||||
@LanguageLocale.general_btnCreate
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Default" Size="Size.Small"
|
||||
StartIcon="@Icons.Material.Filled.ArrowBack" OnClick="() => BtnReturn()">
|
||||
@LanguageLocale.general_btnReturn
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
|
||||
<MudForm @ref="@_form" Model="@exportParams"
|
||||
Validation="@((ExportParamsValidator as StayExportParamsDTOValidator)!.ValidateValue)" ReadOnly="@_isExported">
|
||||
<MudPaper Class="pa-4 my-4" Elevation="3" Height="100%">
|
||||
<MudStack Row style="margin-block: 0.2em;">
|
||||
<MudSelect @bind-Value="exportFormat" Label="@LanguageLocale.dto_StayExportFile_ExportFormat" FullWidth
|
||||
Clearable>
|
||||
@foreach (StayExportFormat option in Enum.GetValues<StayExportFormat>())
|
||||
{
|
||||
<MudSelectItem Value="new Nullable<StayExportFormat>(option)">
|
||||
@Localizer.GetEnumValue(option)
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
<MudSelect @bind-Value="exportParams.ExportType" For="@(() => exportParams.ExportType)"
|
||||
Label="@LanguageLocale.dto_StayExportParams_ExportType" FullWidth Clearable>
|
||||
@foreach (StayExportParamType option in Enum.GetValues<StayExportParamType>())
|
||||
{
|
||||
<MudSelectItem Value="new Nullable<StayExportParamType>(option)">
|
||||
@Localizer.GetEnumValue(option)
|
||||
</MudSelectItem>
|
||||
}
|
||||
</MudSelect>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
@if (_showPeriodFields)
|
||||
{
|
||||
<MudPaper Class="pa-4" Elevation="3" Height="100%">
|
||||
<MudStack Row>
|
||||
<MudDatePicker @bind-Date="exportParams.ExportPeriodStart" For="@(() => exportParams.ExportPeriodStart)"
|
||||
Label="@LanguageLocale.dto_StayExportParams_ExportPeriodStart" Clearable OpenTo="OpenTo.Date" Editable
|
||||
AutoClose="true" />
|
||||
<MudDatePicker @bind-Date="exportParams.ExportPeriodEnd" For="@(() => exportParams.ExportPeriodEnd)"
|
||||
Label="@LanguageLocale.dto_StayExportParams_ExportPeriodEnd" Clearable OpenTo="OpenTo.Date" Editable
|
||||
AutoClose="true" />
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
}
|
||||
|
||||
</MudForm>
|
||||
|
||||
@if (_isExported && exportedFile != null)
|
||||
{
|
||||
<MudPaper Class="pa-4 my-6" Elevation="3" Height="100%">
|
||||
<MudStack>
|
||||
<MudText Typo="Typo.h4">File Exported!</MudText>
|
||||
<MudTextField Value="@Localizer.GetEnumValue(exportedFile.ExportResult)"
|
||||
Label="@LanguageLocale.dto_StayExportFile_ExportResult" FullWidth ReadOnly="true" />
|
||||
<MudTextField Value="@Localizer.GetEnumValue(exportedFile.ExportFormat)"
|
||||
Label="@LanguageLocale.dto_StayExportFile_ExportFormat" FullWidth ReadOnly="true" />
|
||||
<MudButton OnClick="BtnDownloadExportedFile">Download Exported File</MudButton>
|
||||
</MudStack>
|
||||
</MudPaper>
|
||||
}
|
||||
|
||||
@code {
|
||||
MudForm _form = null!;
|
||||
|
||||
StayExportFormat? exportFormat = null;
|
||||
StayExportParamsDTO exportParams = new();
|
||||
StayExportFileDTO? exportedFile = null;
|
||||
|
||||
bool _showPeriodFields => exportParams.ExportType == StayExportParamType.PeriodDateIn;
|
||||
bool _isExported => exportedFile != null;
|
||||
|
||||
|
||||
private void BtnReturn()
|
||||
{
|
||||
Navigation.NavigateTo(GuestConsts.Page_StayExport_List);
|
||||
}
|
||||
|
||||
private async Task BtnCreateExport()
|
||||
{
|
||||
await _form.ValidateAsync();
|
||||
if (!_form.IsValid || exportFormat == null)
|
||||
{
|
||||
userMessage.ShowMessage("Invalid Form!", MessageKind.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
var loadingDialog = await DialogService.ShowAsync<LoadingDialog>();
|
||||
|
||||
var exportResult = await ExportService.ExportStaysByParamsAsync(exportFormat.Value, exportParams);
|
||||
exportedFile = exportResult.Value;
|
||||
loadingDialog.Close();
|
||||
|
||||
if (!exportResult.IsSuccess)
|
||||
{
|
||||
userMessage.ShowResultWithMessage(exportResult, $"Error exporting stays");
|
||||
return;
|
||||
}
|
||||
|
||||
userMessage.ShowMessage(
|
||||
$"Stay exported: {exportResult.ResultCode} with export result: {exportedFile?.ExportResult}",
|
||||
MessageKind.Success);
|
||||
}
|
||||
|
||||
private async Task BtnDownloadExportedFile()
|
||||
{
|
||||
Debug.Assert(exportedFile != null);
|
||||
|
||||
if (string.IsNullOrEmpty(exportedFile.ExportedPath))
|
||||
{
|
||||
userMessage.ShowMessage("Exported File can't be downloaded as no file was saved", MessageKind.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
using Stream dataStream = new MemoryStream();
|
||||
|
||||
Result loadResult = await ExportService.GetExportedFileAsync(exportedFile, dataStream);
|
||||
if (!loadResult.IsSuccess)
|
||||
{
|
||||
userMessage.ShowResultWithMessage(loadResult, "Exported File can't be downloaded");
|
||||
return;
|
||||
}
|
||||
|
||||
dataStream.Seek(0, SeekOrigin.Begin);
|
||||
using var streamRef = new DotNetStreamReference(stream: dataStream);
|
||||
|
||||
var fileName = Path.GetFileName(exportedFile.ExportedPath);
|
||||
await JS.InvokeVoidAsync("downloadFileFromStream", fileName, streamRef);
|
||||
|
||||
userMessage.ShowMessage("Exported File downloaded!", MessageKind.Success);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
@using Somnia.GuestLog.Components.Controls
|
||||
@using Somnia.GuestLog.Services.Entity;
|
||||
@using System.Diagnostics;
|
||||
@@ -1,13 +1,19 @@
|
||||
@using System.Net.Http
|
||||
@using System.Net.Http.Json
|
||||
@using System.Linq;
|
||||
@using Microsoft.AspNetCore.Components.Forms
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@using static Microsoft.AspNetCore.Components.Web.RenderMode
|
||||
@using Microsoft.AspNetCore.Components.Web.Virtualization
|
||||
@using Microsoft.JSInterop
|
||||
@using Microsoft.Extensions.Localization
|
||||
@using MudBlazor
|
||||
@using MudBlazor.Services
|
||||
@using Somnia.GuestLog
|
||||
@using Somnia.GuestLog.Components
|
||||
@using Somnia.GuestLog.Components.Layout
|
||||
@using Somnia.GuestLog.Components.Forms
|
||||
@using Somnia.GuestLog.Components.Controls
|
||||
@using Somnia.GuestLog.Resources
|
||||
@using Somnia.GuestLog.Enums.UI
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Somnia.GuestLog.Enums.Models;
|
||||
|
||||
public enum StayExportFileResult
|
||||
{
|
||||
OK = 0,
|
||||
NoData = 1,
|
||||
ExportError = 2,
|
||||
UploadError = 3,
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Somnia.GuestLog.Enums.Models;
|
||||
|
||||
public enum StayExportFormat
|
||||
{
|
||||
GuestLogJson = 0,
|
||||
SpainParteViajeros = 1,
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Somnia.GuestLog.Enums.Models;
|
||||
|
||||
public enum StayExportParamType
|
||||
{
|
||||
PeriodDateIn = 0,
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Somnia.GuestLog.Enums.Services;
|
||||
|
||||
public enum AddressQueryProvider
|
||||
{
|
||||
Nominatim,
|
||||
GoogleApiV4
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace Somnia.GuestLog.Enums.Services;
|
||||
|
||||
public enum ResultCode
|
||||
{
|
||||
//Common Codes
|
||||
Ok,
|
||||
UnknownError,
|
||||
FailedValidation,
|
||||
NotFound,
|
||||
FileStorageError,
|
||||
|
||||
//Specific Codes
|
||||
GuestInStay,
|
||||
GuestCurrentlyInStay,
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Somnia.GuestLog.Enums.UI;
|
||||
|
||||
public enum FormMode
|
||||
{
|
||||
Create, ReadOnly, Edit
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Somnia.GuestLog.Enums.UI;
|
||||
|
||||
public enum MessageKind
|
||||
{
|
||||
Info, Warning, Error, Success, Normal
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
namespace Somnia.GuestLog;
|
||||
|
||||
public static class GuestConsts
|
||||
{
|
||||
|
||||
public const string Page_GuestDocs_List = "/guest-documents";
|
||||
public const string Page_GuestDocs_New = "/guest-documents/new";
|
||||
public const string Page_GuestDocs_Detail = $"/guest-documents/d/{Page_GuestDocs_Detail_Param_DocId}";
|
||||
public const string Page_GuestDocs_Detail_Param_DocId = "{docId:long}";
|
||||
|
||||
public const string Page_StayEntry_List = "/stayEntries";
|
||||
public const string Page_StayEntry_New = "/stayEntries/new";
|
||||
public const string Page_StayEntry_Detail = $"/stayEntries/d/{Page_StayEntry_Detail_Param_Id}";
|
||||
public const string Page_StayEntry_Detail_Param_Id = "{StayId:long}";
|
||||
|
||||
public const string Page_StayExport_List = "/stayExport";
|
||||
public const string Page_StayExport_New = "/stayExport/new";
|
||||
|
||||
|
||||
public const string QueryParam_ReturnUrl = "returnUrl";
|
||||
|
||||
|
||||
public const string DataList_DocumentTypes = "DocumentType";
|
||||
public const string DataList_GenderOptions = "GenderOption";
|
||||
public const string DataList_CountryCodes = "CountryCode";
|
||||
public const string DataList_PaymentMethods = "PaymentMethod";
|
||||
|
||||
|
||||
public const string CountryCode_ESP = "ESP";
|
||||
|
||||
public const string DocumentType_DNI = "DNI";
|
||||
public const string DocumentType_NIE = "NIE";
|
||||
public const string DocumentType_PASSPORT = "PASSPORT";
|
||||
|
||||
public const string GenderOptions_MALE = "M";
|
||||
public const string GenderOptions_FEMALE = "F";
|
||||
public const string GenderOptions_OTHER = "O";
|
||||
|
||||
public const int GuestDocument_FirstVersion = 1;
|
||||
|
||||
|
||||
public const string EmptyField = "-";
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace Somnia.GuestLog.Infrastructure;
|
||||
|
||||
public static class DbConsts
|
||||
{
|
||||
public const string DbType_Timestamptz = "timestamp with time zone";
|
||||
public const string DbType_Timestamptz_0 = "timestamp(0) with time zone";
|
||||
public const string DbType_Timestamptz_3 = "timestamp(3) with time zone";
|
||||
|
||||
public const string DbType_jsonb = "jsonb";
|
||||
|
||||
public const string PK_NotApply = "N/A";
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Somnia.GuestLog.Models.Entities;
|
||||
|
||||
namespace Somnia.GuestLog.Infrastructure.EntityConfigs;
|
||||
|
||||
public class GuestDocumentEntityConfig : IEntityTypeConfiguration<GuestDocument>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<GuestDocument> builder)
|
||||
{
|
||||
builder.ToTable("GuestDocument");
|
||||
|
||||
//PK
|
||||
builder.HasKey(e => new { e.Id, e.Version });
|
||||
|
||||
builder.Property(e => e.Id)
|
||||
.UseIdentityByDefaultColumn();
|
||||
|
||||
builder.Property(e => e.Version)
|
||||
.IsRequired();
|
||||
|
||||
builder.Property(e => e.DocumentType)
|
||||
.IsRequired()
|
||||
.HasMaxLength(8);
|
||||
builder.Property(e => e.DocumentNum)
|
||||
.IsRequired()
|
||||
.HasMaxLength(64);
|
||||
|
||||
// builder.Property(e => e.IssueDate);
|
||||
|
||||
builder.Property(e => e.SupportNum)
|
||||
.HasMaxLength(10);
|
||||
|
||||
//3 letter code: ISO 3166-1 Alfa-3
|
||||
builder.Property(e => e.Nationality)
|
||||
.HasMaxLength(3);
|
||||
|
||||
builder.Property(e => e.Name)
|
||||
.IsRequired()
|
||||
.HasMaxLength(64);
|
||||
builder.Property(e => e.Surname)
|
||||
.IsRequired()
|
||||
.HasMaxLength(64);
|
||||
builder.Property(e => e.Surname2)
|
||||
.HasMaxLength(64);
|
||||
|
||||
// builder.Property(e => e.BirthDate);
|
||||
|
||||
builder.Property(e => e.Gender)
|
||||
.HasMaxLength(1);
|
||||
|
||||
builder.Property(e => e.PhoneNumber)
|
||||
.HasMaxLength(32);
|
||||
builder.Property(e => e.EmailAddress)
|
||||
.HasMaxLength(256);
|
||||
|
||||
builder.Property(e => e.CreateTime)
|
||||
.IsRequired()
|
||||
.HasColumnType(DbConsts.DbType_Timestamptz_3);
|
||||
builder.Property(e => e.UpdateTime)
|
||||
.IsRequired()
|
||||
.HasColumnType(DbConsts.DbType_Timestamptz_3);
|
||||
builder.Property(e => e.IsLastVersion)
|
||||
.IsRequired();
|
||||
|
||||
|
||||
var addressBuilder = builder.ComplexProperty(e => e.AddressDetails);
|
||||
|
||||
addressBuilder.Property(e => e.Address)
|
||||
.HasMaxLength(128);
|
||||
addressBuilder.Property(e => e.AddressCity)
|
||||
.HasMaxLength(128);
|
||||
addressBuilder.Property(e => e.AddressProvince)
|
||||
.HasMaxLength(128);
|
||||
addressBuilder.Property(e => e.AddressState)
|
||||
.HasMaxLength(128);
|
||||
|
||||
//3 letter code: ISO 3166-1 Alfa-3
|
||||
addressBuilder.Property(e => e.AddressCountry)
|
||||
.IsRequired()
|
||||
.HasMaxLength(3);
|
||||
|
||||
addressBuilder.Property(e => e.ZipCode)
|
||||
.HasMaxLength(12);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Somnia.GuestLog.Models.Entities;
|
||||
|
||||
namespace Somnia.GuestLog.Infrastructure.EntityConfigs;
|
||||
|
||||
public class StayEntryEntityConfig : IEntityTypeConfiguration<StayEntry>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<StayEntry> builder)
|
||||
{
|
||||
builder.ToTable("StayEntry");
|
||||
|
||||
//PK
|
||||
builder.HasKey(e => e.Id);
|
||||
|
||||
builder.Property(e => e.Id)
|
||||
.IsRequired()
|
||||
.UseIdentityByDefaultColumn();
|
||||
|
||||
builder.Property(e => e.DateIn)
|
||||
.IsRequired()
|
||||
.HasColumnType(DbConsts.DbType_Timestamptz_0);
|
||||
builder.Property(e => e.DateOut)
|
||||
.IsRequired()
|
||||
.HasColumnType(DbConsts.DbType_Timestamptz_0);
|
||||
|
||||
builder.Property(e => e.RoomNumber)
|
||||
.HasMaxLength(32);
|
||||
builder.Property(e => e.PaymentMethod)
|
||||
.IsRequired()
|
||||
.HasMaxLength(5);
|
||||
|
||||
|
||||
builder.Property(e => e.CreateTime)
|
||||
.IsRequired()
|
||||
.HasColumnType(DbConsts.DbType_Timestamptz);
|
||||
builder.Property(e => e.UpdateTime)
|
||||
.IsRequired()
|
||||
.HasColumnType(DbConsts.DbType_Timestamptz);
|
||||
|
||||
|
||||
builder.HasMany(e => e.GuestDocuments)
|
||||
.WithMany();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
using Somnia.GuestLog.Models.Entities;
|
||||
|
||||
namespace Somnia.GuestLog.Infrastructure.EntityConfigs;
|
||||
|
||||
public class StayExportFileEntityConfig : IEntityTypeConfiguration<StayExportFile>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<StayExportFile> builder)
|
||||
{
|
||||
builder.ToTable("StayExportFile");
|
||||
|
||||
//PK
|
||||
builder.HasKey(e => e.Id);
|
||||
|
||||
builder.Property(e => e.Id)
|
||||
.IsRequired()
|
||||
.UseIdentityByDefaultColumn();
|
||||
|
||||
builder.ComplexProperty(e => e.ExportParams, e =>
|
||||
{
|
||||
e.ToJson();
|
||||
});
|
||||
|
||||
builder.Property(e => e.ExportedPath)
|
||||
.HasMaxLength(256);
|
||||
|
||||
builder.Property(e => e.ExportDetails)
|
||||
.HasColumnType(DbConsts.DbType_jsonb);
|
||||
|
||||
|
||||
builder.Property(e => e.ExportTime)
|
||||
.IsRequired()
|
||||
.HasColumnType(DbConsts.DbType_Timestamptz);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Somnia.GuestLog.Infrastructure.EntityConfigs;
|
||||
using Somnia.GuestLog.Models.Entities;
|
||||
|
||||
namespace Somnia.GuestLog.Infrastructure;
|
||||
|
||||
public partial class GuestLogContext : DbContext
|
||||
{
|
||||
public GuestLogContext(DbContextOptions<GuestLogContext> options)
|
||||
: base(options)
|
||||
{ }
|
||||
|
||||
public DbSet<GuestDocument> GuestDocuments { get; set; }
|
||||
public DbSet<StayEntry> StayEntries { get; set; }
|
||||
|
||||
public DbSet<StayExportFile> StayExportFiles { get; set; }
|
||||
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.ApplyConfiguration<GuestDocument>(new GuestDocumentEntityConfig());
|
||||
modelBuilder.ApplyConfiguration<StayEntry>(new StayEntryEntityConfig());
|
||||
modelBuilder.ApplyConfiguration<StayExportFile>(new StayExportFileEntityConfig());
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
base.OnModelCreating(modelBuilder);
|
||||
}
|
||||
|
||||
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
||||
|
||||
}
|
||||
Generated
+125
@@ -0,0 +1,125 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using Somnia.GuestLog.Infrastructure;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
{
|
||||
[DbContext(typeof(GuestLogContext))]
|
||||
[Migration("20260618190348_AddTable_GuestDocuments")]
|
||||
partial class AddTable_GuestDocuments
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "10.0.7")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Somnia.GuestLog.Models.GuestDocument", b =>
|
||||
{
|
||||
b.Property<string>("DocumentType")
|
||||
.HasMaxLength(8)
|
||||
.HasColumnType("character varying(8)");
|
||||
|
||||
b.Property<string>("DocumentNum")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<DateOnly>("BirthDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasDefaultValueSql("current_timestamp");
|
||||
|
||||
b.Property<string>("EmailAddress")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<string>("Gender")
|
||||
.HasMaxLength(1)
|
||||
.HasColumnType("character varying(1)");
|
||||
|
||||
b.Property<DateOnly>("IssueDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("Nationality")
|
||||
.IsRequired()
|
||||
.HasMaxLength(3)
|
||||
.HasColumnType("character varying(3)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)");
|
||||
|
||||
b.Property<string>("SupportNum")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("character varying(10)");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("Surname2")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("timestamp with time zone")
|
||||
.HasDefaultValueSql("current_timestamp");
|
||||
|
||||
b.ComplexProperty(typeof(Dictionary<string, object>), "AddressDetails", "Somnia.GuestLog.Models.GuestDocument.AddressDetails#GuestAddress", b1 =>
|
||||
{
|
||||
b1.Property<string>("Address")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressCity")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressCountry")
|
||||
.IsRequired()
|
||||
.HasMaxLength(3)
|
||||
.HasColumnType("character varying(3)");
|
||||
|
||||
b1.Property<string>("AddressProvince")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressState")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("ZipCode")
|
||||
.HasMaxLength(3)
|
||||
.HasColumnType("character varying(3)");
|
||||
});
|
||||
|
||||
b.HasKey("DocumentType", "DocumentNum");
|
||||
|
||||
b.ToTable("GuestDocument", (string)null);
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddTable_GuestDocuments : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "GuestDocument",
|
||||
columns: table => new
|
||||
{
|
||||
DocumentType = table.Column<string>(type: "character varying(8)", maxLength: 8, nullable: false),
|
||||
DocumentNum = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
||||
IssueDate = table.Column<DateOnly>(type: "date", nullable: false),
|
||||
SupportNum = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: true),
|
||||
Nationality = table.Column<string>(type: "character varying(3)", maxLength: 3, nullable: false),
|
||||
Name = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
||||
Surname = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
||||
Surname2 = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
|
||||
BirthDate = table.Column<DateOnly>(type: "date", nullable: false),
|
||||
Gender = table.Column<string>(type: "character varying(1)", maxLength: 1, nullable: true),
|
||||
PhoneNumber = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
|
||||
EmailAddress = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
||||
CreateTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "current_timestamp"),
|
||||
UpdateTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false, defaultValueSql: "current_timestamp"),
|
||||
AddressDetails_Address = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
AddressDetails_AddressCity = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
AddressDetails_AddressCountry = table.Column<string>(type: "character varying(3)", maxLength: 3, nullable: true),
|
||||
AddressDetails_AddressProvince = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
AddressDetails_AddressState = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
AddressDetails_ZipCode = table.Column<string>(type: "character varying(3)", maxLength: 3, nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_GuestDocument", x => new { x.DocumentType, x.DocumentNum });
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "GuestDocument");
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+121
@@ -0,0 +1,121 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using Somnia.GuestLog.Infrastructure;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
{
|
||||
[DbContext(typeof(GuestLogContext))]
|
||||
[Migration("20260621150802_GuestDocumentFixes")]
|
||||
partial class GuestDocumentFixes
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "10.0.7")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.GuestDocument", b =>
|
||||
{
|
||||
b.Property<string>("DocumentType")
|
||||
.HasMaxLength(8)
|
||||
.HasColumnType("character varying(8)");
|
||||
|
||||
b.Property<string>("DocumentNum")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<DateOnly>("BirthDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("EmailAddress")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<string>("Gender")
|
||||
.HasMaxLength(1)
|
||||
.HasColumnType("character varying(1)");
|
||||
|
||||
b.Property<DateOnly>("IssueDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("Nationality")
|
||||
.IsRequired()
|
||||
.HasMaxLength(3)
|
||||
.HasColumnType("character varying(3)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)");
|
||||
|
||||
b.Property<string>("SupportNum")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("character varying(10)");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("Surname2")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.ComplexProperty(typeof(Dictionary<string, object>), "AddressDetails", "Somnia.GuestLog.Models.Entities.GuestDocument.AddressDetails#GuestAddress", b1 =>
|
||||
{
|
||||
b1.Property<string>("Address")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressCity")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressCountry")
|
||||
.IsRequired()
|
||||
.HasMaxLength(3)
|
||||
.HasColumnType("character varying(3)");
|
||||
|
||||
b1.Property<string>("AddressProvince")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressState")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("ZipCode")
|
||||
.HasMaxLength(12)
|
||||
.HasColumnType("character varying(12)");
|
||||
});
|
||||
|
||||
b.HasKey("DocumentType", "DocumentNum");
|
||||
|
||||
b.ToTable("GuestDocument", (string)null);
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class GuestDocumentFixes : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<DateTime>(
|
||||
name: "UpdateTime",
|
||||
table: "GuestDocument",
|
||||
type: "timestamp with time zone",
|
||||
nullable: false,
|
||||
oldClrType: typeof(DateTime),
|
||||
oldType: "timestamp with time zone",
|
||||
oldDefaultValueSql: "current_timestamp");
|
||||
|
||||
migrationBuilder.AlterColumn<DateTime>(
|
||||
name: "CreateTime",
|
||||
table: "GuestDocument",
|
||||
type: "timestamp with time zone",
|
||||
nullable: false,
|
||||
oldClrType: typeof(DateTime),
|
||||
oldType: "timestamp with time zone",
|
||||
oldDefaultValueSql: "current_timestamp");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "AddressDetails_ZipCode",
|
||||
table: "GuestDocument",
|
||||
type: "character varying(12)",
|
||||
maxLength: 12,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "character varying(3)",
|
||||
oldMaxLength: 3,
|
||||
oldNullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AlterColumn<DateTime>(
|
||||
name: "UpdateTime",
|
||||
table: "GuestDocument",
|
||||
type: "timestamp with time zone",
|
||||
nullable: false,
|
||||
defaultValueSql: "current_timestamp",
|
||||
oldClrType: typeof(DateTime),
|
||||
oldType: "timestamp with time zone");
|
||||
|
||||
migrationBuilder.AlterColumn<DateTime>(
|
||||
name: "CreateTime",
|
||||
table: "GuestDocument",
|
||||
type: "timestamp with time zone",
|
||||
nullable: false,
|
||||
defaultValueSql: "current_timestamp",
|
||||
oldClrType: typeof(DateTime),
|
||||
oldType: "timestamp with time zone");
|
||||
|
||||
migrationBuilder.AlterColumn<string>(
|
||||
name: "AddressDetails_ZipCode",
|
||||
table: "GuestDocument",
|
||||
type: "character varying(3)",
|
||||
maxLength: 3,
|
||||
nullable: true,
|
||||
oldClrType: typeof(string),
|
||||
oldType: "character varying(12)",
|
||||
oldMaxLength: 12,
|
||||
oldNullable: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+191
@@ -0,0 +1,191 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using Somnia.GuestLog.Infrastructure;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
{
|
||||
[DbContext(typeof(GuestLogContext))]
|
||||
[Migration("20260813085339_AddTable_StayEntry")]
|
||||
partial class AddTable_StayEntry
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "10.0.7")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("GuestDocumentStayEntry", b =>
|
||||
{
|
||||
b.Property<long>("StayEntryId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<string>("GuestDocumentsDocumentType")
|
||||
.HasColumnType("character varying(8)");
|
||||
|
||||
b.Property<string>("GuestDocumentsDocumentNum")
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.HasKey("StayEntryId", "GuestDocumentsDocumentType", "GuestDocumentsDocumentNum");
|
||||
|
||||
b.HasIndex("GuestDocumentsDocumentType", "GuestDocumentsDocumentNum");
|
||||
|
||||
b.ToTable("GuestDocumentStayEntry");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.GuestDocument", b =>
|
||||
{
|
||||
b.Property<string>("DocumentType")
|
||||
.HasMaxLength(8)
|
||||
.HasColumnType("character varying(8)");
|
||||
|
||||
b.Property<string>("DocumentNum")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<DateOnly>("BirthDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("EmailAddress")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<string>("Gender")
|
||||
.HasMaxLength(1)
|
||||
.HasColumnType("character varying(1)");
|
||||
|
||||
b.Property<DateOnly>("IssueDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("Nationality")
|
||||
.IsRequired()
|
||||
.HasMaxLength(3)
|
||||
.HasColumnType("character varying(3)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)");
|
||||
|
||||
b.Property<string>("SupportNum")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("character varying(10)");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("Surname2")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.ComplexProperty(typeof(Dictionary<string, object>), "AddressDetails", "Somnia.GuestLog.Models.Entities.GuestDocument.AddressDetails#GuestAddress", b1 =>
|
||||
{
|
||||
b1.Property<string>("Address")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressCity")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressCountry")
|
||||
.IsRequired()
|
||||
.HasMaxLength(3)
|
||||
.HasColumnType("character varying(3)");
|
||||
|
||||
b1.Property<string>("AddressProvince")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressState")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("ZipCode")
|
||||
.HasMaxLength(12)
|
||||
.HasColumnType("character varying(12)");
|
||||
});
|
||||
|
||||
b.HasKey("DocumentType", "DocumentNum");
|
||||
|
||||
b.ToTable("GuestDocument", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.StayEntry", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("DateIn")
|
||||
.HasColumnType("timestamp(0) with time zone");
|
||||
|
||||
b.Property<DateTime>("DateOut")
|
||||
.HasColumnType("timestamp(0) with time zone");
|
||||
|
||||
b.Property<string>("PaymentMethod")
|
||||
.IsRequired()
|
||||
.HasMaxLength(5)
|
||||
.HasColumnType("character varying(5)");
|
||||
|
||||
b.Property<int>("RoomCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("RoomNumber")
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("StayEntry", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GuestDocumentStayEntry", b =>
|
||||
{
|
||||
b.HasOne("Somnia.GuestLog.Models.Entities.StayEntry", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("StayEntryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Somnia.GuestLog.Models.Entities.GuestDocument", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("GuestDocumentsDocumentType", "GuestDocumentsDocumentNum")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddTable_StayEntry : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "StayEntry",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
DateIn = table.Column<DateTime>(type: "timestamp(0) with time zone", nullable: false),
|
||||
DateOut = table.Column<DateTime>(type: "timestamp(0) with time zone", nullable: false),
|
||||
RoomCount = table.Column<int>(type: "integer", nullable: false),
|
||||
RoomNumber = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
|
||||
PaymentMethod = table.Column<string>(type: "character varying(5)", maxLength: 5, nullable: false),
|
||||
CreateTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
UpdateTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_StayEntry", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "GuestDocumentStayEntry",
|
||||
columns: table => new
|
||||
{
|
||||
StayEntryId = table.Column<long>(type: "bigint", nullable: false),
|
||||
GuestDocumentsDocumentType = table.Column<string>(type: "character varying(8)", nullable: false),
|
||||
GuestDocumentsDocumentNum = table.Column<string>(type: "character varying(64)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_GuestDocumentStayEntry", x => new { x.StayEntryId, x.GuestDocumentsDocumentType, x.GuestDocumentsDocumentNum });
|
||||
table.ForeignKey(
|
||||
name: "FK_GuestDocumentStayEntry_GuestDocument_GuestDocumentsDocument~",
|
||||
columns: x => new { x.GuestDocumentsDocumentType, x.GuestDocumentsDocumentNum },
|
||||
principalTable: "GuestDocument",
|
||||
principalColumns: new[] { "DocumentType", "DocumentNum" },
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_GuestDocumentStayEntry_StayEntry_StayEntryId",
|
||||
column: x => x.StayEntryId,
|
||||
principalTable: "StayEntry",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_GuestDocumentStayEntry_GuestDocumentsDocumentType_GuestDocu~",
|
||||
table: "GuestDocumentStayEntry",
|
||||
columns: new[] { "GuestDocumentsDocumentType", "GuestDocumentsDocumentNum" });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "GuestDocumentStayEntry");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "StayEntry");
|
||||
}
|
||||
}
|
||||
}
|
||||
+205
@@ -0,0 +1,205 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using Somnia.GuestLog.Infrastructure;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
{
|
||||
[DbContext(typeof(GuestLogContext))]
|
||||
[Migration("20260830201743_GuestDocument_ChangePKToIdAndVersion")]
|
||||
partial class GuestDocument_ChangePKToIdAndVersion
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "10.0.7")
|
||||
.HasAnnotation("Proxies:ChangeTracking", false)
|
||||
.HasAnnotation("Proxies:CheckEquality", false)
|
||||
.HasAnnotation("Proxies:LazyLoading", true)
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("GuestDocumentStayEntry", b =>
|
||||
{
|
||||
b.Property<long>("StayEntryId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("GuestDocumentsId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("GuestDocumentsVersion")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("StayEntryId", "GuestDocumentsId", "GuestDocumentsVersion");
|
||||
|
||||
b.HasIndex("GuestDocumentsId", "GuestDocumentsVersion");
|
||||
|
||||
b.ToTable("GuestDocumentStayEntry");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.GuestDocument", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<int>("Version")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateOnly>("BirthDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("DocumentNum")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("DocumentType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(8)
|
||||
.HasColumnType("character varying(8)");
|
||||
|
||||
b.Property<string>("EmailAddress")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<string>("Gender")
|
||||
.HasMaxLength(1)
|
||||
.HasColumnType("character varying(1)");
|
||||
|
||||
b.Property<DateOnly>("IssueDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("Nationality")
|
||||
.IsRequired()
|
||||
.HasMaxLength(3)
|
||||
.HasColumnType("character varying(3)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)");
|
||||
|
||||
b.Property<string>("SupportNum")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("character varying(10)");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("Surname2")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.ComplexProperty(typeof(Dictionary<string, object>), "AddressDetails", "Somnia.GuestLog.Models.Entities.GuestDocument.AddressDetails#GuestAddress", b1 =>
|
||||
{
|
||||
b1.Property<string>("Address")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressCity")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressCountry")
|
||||
.IsRequired()
|
||||
.HasMaxLength(3)
|
||||
.HasColumnType("character varying(3)");
|
||||
|
||||
b1.Property<string>("AddressProvince")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressState")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("ZipCode")
|
||||
.HasMaxLength(12)
|
||||
.HasColumnType("character varying(12)");
|
||||
});
|
||||
|
||||
b.HasKey("Id", "Version");
|
||||
|
||||
b.ToTable("GuestDocument", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.StayEntry", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("DateIn")
|
||||
.HasColumnType("timestamp(0) with time zone");
|
||||
|
||||
b.Property<DateTime>("DateOut")
|
||||
.HasColumnType("timestamp(0) with time zone");
|
||||
|
||||
b.Property<string>("PaymentMethod")
|
||||
.IsRequired()
|
||||
.HasMaxLength(5)
|
||||
.HasColumnType("character varying(5)");
|
||||
|
||||
b.Property<int>("RoomCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("RoomNumber")
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("StayEntry", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GuestDocumentStayEntry", b =>
|
||||
{
|
||||
b.HasOne("Somnia.GuestLog.Models.Entities.StayEntry", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("StayEntryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Somnia.GuestLog.Models.Entities.GuestDocument", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("GuestDocumentsId", "GuestDocumentsVersion")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class GuestDocument_ChangePKToIdAndVersion : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
//Data don't really matter right now. Just get it working good.
|
||||
//This migration will destry all data, but it's fine.
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "GuestDocumentStayEntry"
|
||||
);
|
||||
|
||||
migrationBuilder.Sql("""DELETE FROM "StayEntry";""");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "GuestDocument"
|
||||
);
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "GuestDocument",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
Version = table.Column<int>(type: "integer", nullable: false),
|
||||
DocumentType = table.Column<string>(type: "character varying(8)", maxLength: 8, nullable: false),
|
||||
DocumentNum = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
||||
IssueDate = table.Column<DateOnly>(type: "date", nullable: false),
|
||||
SupportNum = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: true),
|
||||
Nationality = table.Column<string>(type: "character varying(3)", maxLength: 3, nullable: false),
|
||||
Name = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
||||
Surname = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: false),
|
||||
Surname2 = table.Column<string>(type: "character varying(64)", maxLength: 64, nullable: true),
|
||||
BirthDate = table.Column<DateOnly>(type: "date", nullable: false),
|
||||
Gender = table.Column<string>(type: "character varying(1)", maxLength: 1, nullable: true),
|
||||
PhoneNumber = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: true),
|
||||
EmailAddress = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
||||
CreateTime = table.Column<DateTime>(type: "timestamp(3) with time zone", nullable: false),
|
||||
UpdateTime = table.Column<DateTime>(type: "timestamp(3) with time zone", nullable: false),
|
||||
IsLastVersion = table.Column<bool>(type: "boolean", nullable: false),
|
||||
AddressDetails_Address = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
AddressDetails_AddressCity = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
AddressDetails_AddressCountry = table.Column<string>(type: "character varying(3)", maxLength: 3, nullable: true),
|
||||
AddressDetails_AddressProvince = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
AddressDetails_AddressState = table.Column<string>(type: "character varying(128)", maxLength: 128, nullable: true),
|
||||
AddressDetails_ZipCode = table.Column<string>(type: "character varying(12)", maxLength: 12, nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_GuestDocument", x => new { x.Id, x.Version });
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
//Existing index for "DocType" and "DocNum" can be useful, so let's keep it.
|
||||
migrationBuilder.CreateTable(
|
||||
name: "GuestDocumentStayEntry",
|
||||
columns: table => new
|
||||
{
|
||||
StayEntryId = table.Column<long>(type: "bigint", nullable: false),
|
||||
GuestDocumentsId = table.Column<long>(type: "bigint", nullable: false),
|
||||
GuestDocumentsVersion = table.Column<int>(type: "integer", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_GuestDocumentStayEntry", x => new { x.StayEntryId, x.GuestDocumentsId, x.GuestDocumentsVersion });
|
||||
table.ForeignKey(
|
||||
name: "FK_GuestDocumentStayEntry_GuestDocument_GuestDocumentsId_Guest~",
|
||||
columns: x => new { x.GuestDocumentsId, x.GuestDocumentsVersion },
|
||||
principalTable: "GuestDocument",
|
||||
principalColumns: new[] { "Id", "Version" },
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_GuestDocumentStayEntry_StayEntry_StayEntryId",
|
||||
column: x => x.StayEntryId,
|
||||
principalTable: "StayEntry",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_GuestDocumentStayEntry_GuestDocumentsId_GuestDocumentsVersi~",
|
||||
table: "GuestDocumentStayEntry",
|
||||
columns: new[] { "GuestDocumentsId", "GuestDocumentsVersion" });
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
throw new NotSupportedException("Rollback is not supported for this migration!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Generated
+249
@@ -0,0 +1,249 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using Somnia.GuestLog.Infrastructure;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
{
|
||||
[DbContext(typeof(GuestLogContext))]
|
||||
[Migration("20260901161146_AddTable_StayExportFile")]
|
||||
partial class AddTable_StayExportFile
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "10.0.7")
|
||||
.HasAnnotation("Proxies:ChangeTracking", false)
|
||||
.HasAnnotation("Proxies:CheckEquality", false)
|
||||
.HasAnnotation("Proxies:LazyLoading", true)
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("GuestDocumentStayEntry", b =>
|
||||
{
|
||||
b.Property<long>("StayEntryId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("GuestDocumentsId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("GuestDocumentsVersion")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("StayEntryId", "GuestDocumentsId", "GuestDocumentsVersion");
|
||||
|
||||
b.HasIndex("GuestDocumentsId", "GuestDocumentsVersion");
|
||||
|
||||
b.ToTable("GuestDocumentStayEntry");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.GuestDocument", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<int>("Version")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateOnly>("BirthDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("timestamp(3) with time zone");
|
||||
|
||||
b.Property<string>("DocumentNum")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("DocumentType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(8)
|
||||
.HasColumnType("character varying(8)");
|
||||
|
||||
b.Property<string>("EmailAddress")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<string>("Gender")
|
||||
.HasMaxLength(1)
|
||||
.HasColumnType("character varying(1)");
|
||||
|
||||
b.Property<bool>("IsLastVersion")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<DateOnly>("IssueDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("Nationality")
|
||||
.IsRequired()
|
||||
.HasMaxLength(3)
|
||||
.HasColumnType("character varying(3)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)");
|
||||
|
||||
b.Property<string>("SupportNum")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("character varying(10)");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("Surname2")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("timestamp(3) with time zone");
|
||||
|
||||
b.ComplexProperty(typeof(Dictionary<string, object>), "AddressDetails", "Somnia.GuestLog.Models.Entities.GuestDocument.AddressDetails#GuestAddress", b1 =>
|
||||
{
|
||||
b1.Property<string>("Address")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressCity")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressCountry")
|
||||
.IsRequired()
|
||||
.HasMaxLength(3)
|
||||
.HasColumnType("character varying(3)");
|
||||
|
||||
b1.Property<string>("AddressProvince")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressState")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("ZipCode")
|
||||
.HasMaxLength(12)
|
||||
.HasColumnType("character varying(12)");
|
||||
});
|
||||
|
||||
b.HasKey("Id", "Version");
|
||||
|
||||
b.ToTable("GuestDocument", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.StayEntry", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("DateIn")
|
||||
.HasColumnType("timestamp(0) with time zone");
|
||||
|
||||
b.Property<DateTime>("DateOut")
|
||||
.HasColumnType("timestamp(0) with time zone");
|
||||
|
||||
b.Property<string>("PaymentMethod")
|
||||
.IsRequired()
|
||||
.HasMaxLength(5)
|
||||
.HasColumnType("character varying(5)");
|
||||
|
||||
b.Property<int>("RoomCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("RoomNumber")
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("StayEntry", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.StayExportFile", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<int>("ExportFormat")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ExportResult")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("ExportTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("ExportedPath")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.ComplexProperty(typeof(Dictionary<string, object>), "ExportParams", "Somnia.GuestLog.Models.Entities.StayExportFile.ExportParams#StayExportParams", b1 =>
|
||||
{
|
||||
b1.IsRequired();
|
||||
|
||||
b1.Property<DateTime?>("ExportPeriodEnd");
|
||||
|
||||
b1.Property<DateTime?>("ExportPeriodStart");
|
||||
|
||||
b1.Property<int>("ExportType");
|
||||
|
||||
b1
|
||||
.ToJson("ExportParams")
|
||||
.HasColumnType("jsonb");
|
||||
});
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("StayExportFile", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GuestDocumentStayEntry", b =>
|
||||
{
|
||||
b.HasOne("Somnia.GuestLog.Models.Entities.StayEntry", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("StayEntryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Somnia.GuestLog.Models.Entities.GuestDocument", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("GuestDocumentsId", "GuestDocumentsVersion")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddTable_StayExportFile : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "StayExportFile",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<long>(type: "bigint", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
ExportFormat = table.Column<int>(type: "integer", nullable: false),
|
||||
ExportResult = table.Column<int>(type: "integer", nullable: false),
|
||||
ExportedPath = table.Column<string>(type: "character varying(256)", maxLength: 256, nullable: true),
|
||||
ExportTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
ExportParams = table.Column<string>(type: "jsonb", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_StayExportFile", x => x.Id);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "StayExportFile");
|
||||
}
|
||||
}
|
||||
}
|
||||
+252
@@ -0,0 +1,252 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using Somnia.GuestLog.Infrastructure;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
{
|
||||
[DbContext(typeof(GuestLogContext))]
|
||||
[Migration("20260908172441_StayExportFile_AddColumn_ExportDetails")]
|
||||
partial class StayExportFile_AddColumn_ExportDetails
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "10.0.7")
|
||||
.HasAnnotation("Proxies:ChangeTracking", false)
|
||||
.HasAnnotation("Proxies:CheckEquality", false)
|
||||
.HasAnnotation("Proxies:LazyLoading", true)
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("GuestDocumentStayEntry", b =>
|
||||
{
|
||||
b.Property<long>("StayEntryId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("GuestDocumentsId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("GuestDocumentsVersion")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("StayEntryId", "GuestDocumentsId", "GuestDocumentsVersion");
|
||||
|
||||
b.HasIndex("GuestDocumentsId", "GuestDocumentsVersion");
|
||||
|
||||
b.ToTable("GuestDocumentStayEntry");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.GuestDocument", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<int>("Version")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateOnly>("BirthDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("timestamp(3) with time zone");
|
||||
|
||||
b.Property<string>("DocumentNum")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("DocumentType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(8)
|
||||
.HasColumnType("character varying(8)");
|
||||
|
||||
b.Property<string>("EmailAddress")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<string>("Gender")
|
||||
.HasMaxLength(1)
|
||||
.HasColumnType("character varying(1)");
|
||||
|
||||
b.Property<bool>("IsLastVersion")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<DateOnly>("IssueDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("Nationality")
|
||||
.IsRequired()
|
||||
.HasMaxLength(3)
|
||||
.HasColumnType("character varying(3)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)");
|
||||
|
||||
b.Property<string>("SupportNum")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("character varying(10)");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("Surname2")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("timestamp(3) with time zone");
|
||||
|
||||
b.ComplexProperty(typeof(Dictionary<string, object>), "AddressDetails", "Somnia.GuestLog.Models.Entities.GuestDocument.AddressDetails#GuestAddress", b1 =>
|
||||
{
|
||||
b1.Property<string>("Address")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressCity")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressCountry")
|
||||
.IsRequired()
|
||||
.HasMaxLength(3)
|
||||
.HasColumnType("character varying(3)");
|
||||
|
||||
b1.Property<string>("AddressProvince")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressState")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("ZipCode")
|
||||
.HasMaxLength(12)
|
||||
.HasColumnType("character varying(12)");
|
||||
});
|
||||
|
||||
b.HasKey("Id", "Version");
|
||||
|
||||
b.ToTable("GuestDocument", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.StayEntry", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("DateIn")
|
||||
.HasColumnType("timestamp(0) with time zone");
|
||||
|
||||
b.Property<DateTime>("DateOut")
|
||||
.HasColumnType("timestamp(0) with time zone");
|
||||
|
||||
b.Property<string>("PaymentMethod")
|
||||
.IsRequired()
|
||||
.HasMaxLength(5)
|
||||
.HasColumnType("character varying(5)");
|
||||
|
||||
b.Property<int>("RoomCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("RoomNumber")
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("StayEntry", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.StayExportFile", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<string>("ExportDetails")
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<int>("ExportFormat")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ExportResult")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("ExportTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("ExportedPath")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.ComplexProperty(typeof(Dictionary<string, object>), "ExportParams", "Somnia.GuestLog.Models.Entities.StayExportFile.ExportParams#StayExportParams", b1 =>
|
||||
{
|
||||
b1.IsRequired();
|
||||
|
||||
b1.Property<DateTime?>("ExportPeriodEnd");
|
||||
|
||||
b1.Property<DateTime?>("ExportPeriodStart");
|
||||
|
||||
b1.Property<int>("ExportType");
|
||||
|
||||
b1
|
||||
.ToJson("ExportParams")
|
||||
.HasColumnType("jsonb");
|
||||
});
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("StayExportFile", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GuestDocumentStayEntry", b =>
|
||||
{
|
||||
b.HasOne("Somnia.GuestLog.Models.Entities.StayEntry", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("StayEntryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Somnia.GuestLog.Models.Entities.GuestDocument", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("GuestDocumentsId", "GuestDocumentsVersion")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class StayExportFile_AddColumn_ExportDetails : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "ExportDetails",
|
||||
table: "StayExportFile",
|
||||
type: "jsonb",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ExportDetails",
|
||||
table: "StayExportFile");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
using Somnia.GuestLog.Infrastructure;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||
{
|
||||
[DbContext(typeof(GuestLogContext))]
|
||||
partial class GuestLogContextModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "10.0.7")
|
||||
.HasAnnotation("Proxies:ChangeTracking", false)
|
||||
.HasAnnotation("Proxies:CheckEquality", false)
|
||||
.HasAnnotation("Proxies:LazyLoading", true)
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||
|
||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("GuestDocumentStayEntry", b =>
|
||||
{
|
||||
b.Property<long>("StayEntryId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<long>("GuestDocumentsId")
|
||||
.HasColumnType("bigint");
|
||||
|
||||
b.Property<int>("GuestDocumentsVersion")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.HasKey("StayEntryId", "GuestDocumentsId", "GuestDocumentsVersion");
|
||||
|
||||
b.HasIndex("GuestDocumentsId", "GuestDocumentsVersion");
|
||||
|
||||
b.ToTable("GuestDocumentStayEntry");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.GuestDocument", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<int>("Version")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateOnly>("BirthDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("timestamp(3) with time zone");
|
||||
|
||||
b.Property<string>("DocumentNum")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("DocumentType")
|
||||
.IsRequired()
|
||||
.HasMaxLength(8)
|
||||
.HasColumnType("character varying(8)");
|
||||
|
||||
b.Property<string>("EmailAddress")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.Property<string>("Gender")
|
||||
.HasMaxLength(1)
|
||||
.HasColumnType("character varying(1)");
|
||||
|
||||
b.Property<bool>("IsLastVersion")
|
||||
.HasColumnType("boolean");
|
||||
|
||||
b.Property<DateOnly>("IssueDate")
|
||||
.HasColumnType("date");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("Nationality")
|
||||
.IsRequired()
|
||||
.HasMaxLength(3)
|
||||
.HasColumnType("character varying(3)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)");
|
||||
|
||||
b.Property<string>("SupportNum")
|
||||
.HasMaxLength(10)
|
||||
.HasColumnType("character varying(10)");
|
||||
|
||||
b.Property<string>("Surname")
|
||||
.IsRequired()
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<string>("Surname2")
|
||||
.HasMaxLength(64)
|
||||
.HasColumnType("character varying(64)");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("timestamp(3) with time zone");
|
||||
|
||||
b.ComplexProperty(typeof(Dictionary<string, object>), "AddressDetails", "Somnia.GuestLog.Models.Entities.GuestDocument.AddressDetails#GuestAddress", b1 =>
|
||||
{
|
||||
b1.Property<string>("Address")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressCity")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressCountry")
|
||||
.IsRequired()
|
||||
.HasMaxLength(3)
|
||||
.HasColumnType("character varying(3)");
|
||||
|
||||
b1.Property<string>("AddressProvince")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("AddressState")
|
||||
.HasMaxLength(128)
|
||||
.HasColumnType("character varying(128)");
|
||||
|
||||
b1.Property<string>("ZipCode")
|
||||
.HasMaxLength(12)
|
||||
.HasColumnType("character varying(12)");
|
||||
});
|
||||
|
||||
b.HasKey("Id", "Version");
|
||||
|
||||
b.ToTable("GuestDocument", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.StayEntry", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<DateTime>("CreateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<DateTime>("DateIn")
|
||||
.HasColumnType("timestamp(0) with time zone");
|
||||
|
||||
b.Property<DateTime>("DateOut")
|
||||
.HasColumnType("timestamp(0) with time zone");
|
||||
|
||||
b.Property<string>("PaymentMethod")
|
||||
.IsRequired()
|
||||
.HasMaxLength(5)
|
||||
.HasColumnType("character varying(5)");
|
||||
|
||||
b.Property<int>("RoomCount")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<string>("RoomNumber")
|
||||
.HasMaxLength(32)
|
||||
.HasColumnType("character varying(32)");
|
||||
|
||||
b.Property<DateTime>("UpdateTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("StayEntry", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Somnia.GuestLog.Models.Entities.StayExportFile", b =>
|
||||
{
|
||||
b.Property<long>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("bigint");
|
||||
|
||||
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("Id"));
|
||||
|
||||
b.Property<string>("ExportDetails")
|
||||
.HasColumnType("jsonb");
|
||||
|
||||
b.Property<int>("ExportFormat")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<int>("ExportResult")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<DateTime>("ExportTime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
b.Property<string>("ExportedPath")
|
||||
.HasMaxLength(256)
|
||||
.HasColumnType("character varying(256)");
|
||||
|
||||
b.ComplexProperty(typeof(Dictionary<string, object>), "ExportParams", "Somnia.GuestLog.Models.Entities.StayExportFile.ExportParams#StayExportParams", b1 =>
|
||||
{
|
||||
b1.IsRequired();
|
||||
|
||||
b1.Property<DateTime?>("ExportPeriodEnd");
|
||||
|
||||
b1.Property<DateTime?>("ExportPeriodStart");
|
||||
|
||||
b1.Property<int>("ExportType");
|
||||
|
||||
b1
|
||||
.ToJson("ExportParams")
|
||||
.HasColumnType("jsonb");
|
||||
});
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("StayExportFile", (string)null);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("GuestDocumentStayEntry", b =>
|
||||
{
|
||||
b.HasOne("Somnia.GuestLog.Models.Entities.StayEntry", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("StayEntryId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Somnia.GuestLog.Models.Entities.GuestDocument", null)
|
||||
.WithMany()
|
||||
.HasForeignKey("GuestDocumentsId", "GuestDocumentsVersion")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using Somnia.GuestLog.Enums.Services;
|
||||
|
||||
namespace Somnia.GuestLog.Models.Configuration;
|
||||
|
||||
public class AddressQueryConfig
|
||||
{
|
||||
public const string SectionName = "AddressQuery";
|
||||
|
||||
public bool EnableAddressQuery { get; set; }
|
||||
public AddressQueryProvider? Provider { get; set; }
|
||||
public string? ServiceURL { get; set; }
|
||||
public string? ApiKey { get; set; }
|
||||
public string? UserAgent { get; set; }
|
||||
public string? ResultLang { get; set; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Somnia.GuestLog.Models.Configuration;
|
||||
|
||||
public class StayExportConfig
|
||||
{
|
||||
public const string SectionName = "StayExport";
|
||||
|
||||
public bool EnableStayExport { get; set; } = false;
|
||||
public string? ExportStorageConnectionString { get; set; }
|
||||
public bool UseSubdirectoryByFormat { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Somnia.GuestLog.Models.Configuration;
|
||||
|
||||
public class StayExportSpainParteViajerosConfig
|
||||
{
|
||||
public const string SectionName = "StayExportSpainParteViajeros";
|
||||
|
||||
public bool InternetAvailable { get; set; } = false;
|
||||
public string? CodigoEstablecimiento { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
namespace Somnia.GuestLog.Models.DTOs;
|
||||
|
||||
public class AddressResultDTO
|
||||
{
|
||||
public string? HouseNumber { get; set; }
|
||||
public string? AddressRoad { get; set; }
|
||||
public string? AddressCity { get; set; }
|
||||
public string? AddressProvince { get; set; }
|
||||
public string? AddressState { get; set; }
|
||||
public string? AddressCountry { get; set; }
|
||||
public string? ZipCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// CountryCode in ISO3166-1:alpha3
|
||||
/// </summary>
|
||||
public string? AddressCountryCode { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace Somnia.GuestLog.Models.DTOs;
|
||||
|
||||
public class GuestDocFilterDTO
|
||||
{
|
||||
public string? DocumentType { get; set; }
|
||||
public string? DocumentNumber { get; set; }
|
||||
|
||||
public string? Name { get; set; }
|
||||
public string? Surname { get; set; }
|
||||
|
||||
public string? PhoneNumber { get; set; }
|
||||
|
||||
public bool OnlyLastVersion { get; set; }
|
||||
|
||||
|
||||
public bool IsEmpty => string.IsNullOrEmpty(DocumentType)
|
||||
&& string.IsNullOrEmpty(DocumentNumber)
|
||||
&& string.IsNullOrEmpty(Name)
|
||||
&& string.IsNullOrEmpty(Surname)
|
||||
&& string.IsNullOrEmpty(PhoneNumber);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
namespace Somnia.GuestLog.Models.DTOs;
|
||||
|
||||
public class GuestDocIdDTO
|
||||
{
|
||||
public required string DocumentType { get; set; }
|
||||
public required string DocumentNum { get; set; }
|
||||
|
||||
|
||||
public static string EncodeAsString(GuestDocIdDTO docId)
|
||||
{
|
||||
return $"{docId.DocumentType}-{docId.DocumentNum}";
|
||||
}
|
||||
|
||||
public static GuestDocIdDTO? DecodeFromString(string str)
|
||||
{
|
||||
var parts = str.Split("-");
|
||||
if (parts.Length < 2)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new()
|
||||
{
|
||||
DocumentType = parts[0],
|
||||
DocumentNum = parts[1]
|
||||
};
|
||||
}
|
||||
|
||||
public static GuestDocIdDTO? BuildFromDto(GuestDocumentDTO? dto)
|
||||
{
|
||||
if (dto is null || dto.DocumentType is null || dto.DocumentNum is null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return new()
|
||||
{
|
||||
DocumentType = dto.DocumentType,
|
||||
DocumentNum = dto.DocumentNum
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
namespace Somnia.GuestLog.Models.DTOs;
|
||||
|
||||
public class GuestDocumentDTO
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
public int? Version { get; set; }
|
||||
|
||||
public string? DocumentType { get; set; }
|
||||
public string? DocumentNum { get; set; }
|
||||
|
||||
public DateTime? IssueDate { get; set; }
|
||||
public string? SupportNum { get; set; }
|
||||
|
||||
public string? Nationality { get; set; }
|
||||
|
||||
public string? Name { get; set; }
|
||||
public string? Surname { get; set; }
|
||||
public string? Surname2 { get; set; }
|
||||
|
||||
public DateTime? BirthDate { get; set; }
|
||||
public string? Gender { get; set; }
|
||||
|
||||
public string? PhoneNumber { get; set; }
|
||||
public string? EmailAddress { get; set; }
|
||||
|
||||
|
||||
public string? Address { get; set; }
|
||||
public string? AddressCity { get; set; }
|
||||
public string? AddressProvince { get; set; }
|
||||
public string? AddressState { get; set; }
|
||||
public string? AddressCountry { get; set; }
|
||||
public string? ZipCode { get; set; }
|
||||
|
||||
|
||||
public DateTime? CreateTime { get; set; }
|
||||
public DateTime? UpdateTime { get; set; }
|
||||
|
||||
|
||||
public string FullKey => $"{Id}-{Version}";
|
||||
public string FullDocument => $"{DocumentType ?? "???"}-{DocumentNum ?? "???"}";
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using Somnia.GuestLog.Enums.Services;
|
||||
|
||||
namespace Somnia.GuestLog.Models.DTOs;
|
||||
|
||||
public interface IResult
|
||||
{
|
||||
bool IsSuccess { get; }
|
||||
ResultCode ResultCode { get; }
|
||||
object[]? Context { get; }
|
||||
}
|
||||
|
||||
public sealed record Result(
|
||||
bool IsSuccess,
|
||||
ResultCode ResultCode,
|
||||
params object[]? Context
|
||||
) : IResult
|
||||
{
|
||||
public static Result Ok() => new(IsSuccess: true, ResultCode: ResultCode.Ok, Context: null);
|
||||
|
||||
public static Result Fail(ResultCode resultCode) => new(IsSuccess: false, resultCode, Context: null);
|
||||
public static Result FailWithContext(ResultCode resultCode, params object[] context)
|
||||
=> new(IsSuccess: false, resultCode, context);
|
||||
public static Result FailUnknownError()
|
||||
=> new(IsSuccess: false, ResultCode: ResultCode.UnknownError, Context: null);
|
||||
|
||||
public bool IsUnknownError => !IsSuccess && ResultCode == ResultCode.UnknownError;
|
||||
}
|
||||
|
||||
public sealed record Result<T>(
|
||||
bool IsSuccess,
|
||||
T? Value,
|
||||
ResultCode ResultCode,
|
||||
params object[]? Context
|
||||
) : IResult
|
||||
{
|
||||
public static Result<T> Ok(T value) => new(IsSuccess: true, value, ResultCode: ResultCode.Ok, Context: null);
|
||||
public static Result<T> Fail(ResultCode resultCode) => new(IsSuccess: false, Value: default, resultCode, Context: null);
|
||||
public static Result<T> FailWithContext(ResultCode resultCode, params object[] context)
|
||||
=> new(IsSuccess: false, Value: default, resultCode, context);
|
||||
|
||||
public bool IsUnknownError => !IsSuccess && ResultCode == ResultCode.UnknownError;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace Somnia.GuestLog.Models.DTOs;
|
||||
|
||||
public class StayEntryDTO
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
public DateTime? DateIn { get; set; }
|
||||
public DateTime? DateOut { get; set; }
|
||||
|
||||
public int? RoomCount { get; set; }
|
||||
public string? RoomNumber { get; set; }
|
||||
public string? PaymentMethod { get; set; }
|
||||
|
||||
|
||||
public List<GuestDocumentDTO>? GuestDocuments { get; set; } = null;
|
||||
|
||||
|
||||
public DateTime? CreateTime { get; set; }
|
||||
public DateTime? UpdateTime { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Somnia.GuestLog.Models.DTOs;
|
||||
|
||||
public class StayEntryFilterDTO
|
||||
{
|
||||
public DateTime? DateInStart { get; set; }
|
||||
public DateTime? DateInEnd { get; set; }
|
||||
|
||||
public string? RoomNumber { get; set; }
|
||||
public string? PaymentMethod { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using Somnia.GuestLog.Enums.Models;
|
||||
|
||||
namespace Somnia.GuestLog.Models.DTOs;
|
||||
|
||||
public class StayExportFileDTO
|
||||
{
|
||||
public long? Id { get; set; }
|
||||
|
||||
public StayExportFormat? ExportFormat { get; set; }
|
||||
|
||||
public StayExportParamsDTO? ExportParams { get; set; }
|
||||
|
||||
public StayExportFileResult? ExportResult { get; set; }
|
||||
|
||||
public string? ExportedPath { get; set; }
|
||||
|
||||
public string? ExportDetails { get; set; }
|
||||
|
||||
|
||||
public DateTime? ExportTime { get; set; }
|
||||
}
|
||||
|
||||
public class StayExportParamsDTO
|
||||
{
|
||||
public StayExportParamType? ExportType { get; set; }
|
||||
|
||||
public DateTime? ExportPeriodStart { get; set; }
|
||||
public DateTime? ExportPeriodEnd { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Somnia.GuestLog.Models.Entities;
|
||||
|
||||
public abstract class BaseEntity
|
||||
{
|
||||
public abstract string GetFullKey();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using Somnia.GuestLog.Infrastructure;
|
||||
|
||||
namespace Somnia.GuestLog.Models.Entities;
|
||||
|
||||
public class GuestAddress : BaseEntity
|
||||
{
|
||||
public string? Address { get; set; }
|
||||
public string? AddressCity { get; set; }
|
||||
public string? AddressProvince { get; set; }
|
||||
public string? AddressState { get; set; }
|
||||
public required string AddressCountry { get; set; }
|
||||
public string? ZipCode { get; set; }
|
||||
|
||||
public override string GetFullKey() => DbConsts.PK_NotApply;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
namespace Somnia.GuestLog.Models.Entities;
|
||||
|
||||
public class GuestDocument : BaseEntity
|
||||
{
|
||||
public long Id { get; set; }
|
||||
public int Version { get; set; }
|
||||
|
||||
public required string DocumentType { get; set; }
|
||||
public required string DocumentNum { get; set; }
|
||||
|
||||
public required DateOnly IssueDate { get; set; }
|
||||
public string? SupportNum { get; set; }
|
||||
|
||||
public required string Nationality { get; set; }
|
||||
|
||||
public required string Name { get; set; }
|
||||
public required string Surname { get; set; }
|
||||
public string? Surname2 { get; set; }
|
||||
|
||||
public required DateOnly BirthDate { get; set; }
|
||||
public string? Gender { get; set; }
|
||||
|
||||
public GuestAddress? AddressDetails { get; set; }
|
||||
|
||||
public string? PhoneNumber { get; set; }
|
||||
public string? EmailAddress { get; set; }
|
||||
|
||||
//Generated Properties.
|
||||
public required DateTime CreateTime { get; set; }
|
||||
public required DateTime UpdateTime { get; set; }
|
||||
|
||||
public required bool IsLastVersion { get; set; }
|
||||
|
||||
|
||||
public override string GetFullKey() => $"{Id}-{Version}";
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
namespace Somnia.GuestLog.Models.Entities;
|
||||
|
||||
public class StayEntry : BaseEntity
|
||||
{
|
||||
public long Id { get; set; }
|
||||
|
||||
public required DateTime DateIn { get; set; }
|
||||
public required DateTime DateOut { get; set; }
|
||||
|
||||
public required int RoomCount { get; set; }
|
||||
public string? RoomNumber { get; set; }
|
||||
|
||||
public required string PaymentMethod { get; set; }
|
||||
|
||||
public virtual ICollection<GuestDocument> GuestDocuments { get; } = [];
|
||||
|
||||
|
||||
//Generated Properties.
|
||||
public required DateTime CreateTime { get; set; }
|
||||
public required DateTime UpdateTime { get; set; }
|
||||
|
||||
|
||||