SHA256
GuestDocument - Improvements to GuestDocument creation:
- IssueDate is now Nullable. Is not required for DNI and NIE document types. - Improvements in SupportNumber for NIE documents. - Address search can now be skipped.
This commit is contained in:
@@ -6,53 +6,61 @@
|
|||||||
|
|
||||||
@inject IDataListService dataListService;
|
@inject IDataListService dataListService;
|
||||||
@inject IValidator<GuestDocumentDTO> guestDocValidator;
|
@inject IValidator<GuestDocumentDTO> guestDocValidator;
|
||||||
|
@inject IUserMessageService userMessage;
|
||||||
|
|
||||||
|
|
||||||
<MudForm @ref="@_form" Model="@Model" Validation="@((guestDocValidator as GuestDocumentDTOValidator)!.ValidateValue)" ValidationDelay="0"
|
<MudForm @ref="@_form" Model="@Model" Validation="@((guestDocValidator as GuestDocumentDTOValidator)!.ValidateValue)"
|
||||||
ReadOnly="@ReadOnly">
|
ValidationDelay="0" ReadOnly="@ReadOnly">
|
||||||
<MudGrid>
|
<MudGrid>
|
||||||
<MudItem xs="12" md="6">
|
<MudItem xs="12" md="6">
|
||||||
<MudPaper Class="pa-4" Elevation="3" Height="100%">
|
<MudPaper Class="pa-4" Elevation="3" Height="100%">
|
||||||
<MudText Typo="Typo.subtitle1" Align="Align.Center">@LanguageLocale.control_GuestDocForm_sectionDocument</MudText>
|
<MudText Typo="Typo.subtitle1" Align="Align.Center">
|
||||||
|
@LanguageLocale.control_GuestDocForm_sectionDocument
|
||||||
|
</MudText>
|
||||||
<MudDivider DividerType="DividerType.Middle" Class="mb-4" />
|
<MudDivider DividerType="DividerType.Middle" Class="mb-4" />
|
||||||
<MudStack Row style="@FieldMarginY">
|
<MudStack Row style="@FieldMarginY">
|
||||||
<MudSelect @bind-Value="Model.DocumentType" For="@(() => Model.DocumentType)" Label="@LanguageLocale.dto_GuestDocument_DocumentType"
|
<MudSelect @bind-Value="Model.DocumentType" For="@(() => Model.DocumentType)"
|
||||||
Required ReadOnly="@ReadOnlyDocId">
|
Label="@LanguageLocale.dto_GuestDocument_DocumentType" Required ReadOnly="@ReadOnlyDocId">
|
||||||
@foreach (string docType in dataListService.GetDataListByName(GuestConsts.DataList_DocumentTypes))
|
@foreach (string docType in
|
||||||
|
dataListService.GetDataListByName(GuestConsts.DataList_DocumentTypes))
|
||||||
{
|
{
|
||||||
<MudSelectItem Value="docType">
|
<MudSelectItem Value="docType">
|
||||||
@dataListService.GetLocalizedValue(GuestConsts.DataList_DocumentTypes, docType)
|
@dataListService.GetLocalizedValue(GuestConsts.DataList_DocumentTypes, docType)
|
||||||
</MudSelectItem>
|
</MudSelectItem>
|
||||||
}
|
}
|
||||||
</MudSelect>
|
</MudSelect>
|
||||||
<MudTextField @bind-Value="Model.DocumentNum" For="@(() => Model.DocumentNum)" Label="@LanguageLocale.dto_GuestDocument_DocumentNum"
|
<MudTextField @bind-Value="Model.DocumentNum" For="@(() => Model.DocumentNum)"
|
||||||
Required ReadOnly="@ReadOnlyDocId" />
|
Label="@LanguageLocale.dto_GuestDocument_DocumentNum" Required ReadOnly="@ReadOnlyDocId" />
|
||||||
</MudStack>
|
</MudStack>
|
||||||
|
|
||||||
<MudStack Row style="@FieldMarginY">
|
<MudStack Row style="@FieldMarginY">
|
||||||
<MudDatePicker @bind-Date="Model.IssueDate" For="@(() => Model.IssueDate)" Label="@LanguageLocale.dto_GuestDocument_IssueDate"
|
<MudDatePicker @bind-Date="Model.IssueDate" For="@(() => Model.IssueDate)"
|
||||||
Clearable OpenTo="OpenTo.Year" Editable />
|
Label="@LanguageLocale.dto_GuestDocument_IssueDate" Clearable OpenTo="OpenTo.Year" Editable />
|
||||||
|
|
||||||
<MudTextField @bind-Value="Model.SupportNum" For="@(() => Model.SupportNum)" Label="@LanguageLocale.dto_GuestDocument_SupportNum"
|
<MudTextField @bind-Value="Model.SupportNum" For="@(() => Model.SupportNum)"
|
||||||
Required="@isSuportNumberRequired" Mask="@(new PatternMask("aaa000000"))"
|
Label="@LanguageLocale.dto_GuestDocument_SupportNum" Required="@isSuportNumberRequired"
|
||||||
|
Mask="SuportNumberPatternMask"
|
||||||
OnBlur="@(() => Model.SupportNum = Model.SupportNum?.ToUpper())" />
|
OnBlur="@(() => Model.SupportNum = Model.SupportNum?.ToUpper())" />
|
||||||
</MudStack>
|
</MudStack>
|
||||||
|
|
||||||
<MudAutocomplete T="string" @bind-Value="Model.Nationality" For="@(() => Model.Nationality)" Label="@LanguageLocale.dto_GuestDocument_Nationality"
|
<MudAutocomplete T="string" @bind-Value="Model.Nationality" For="@(() => Model.Nationality)"
|
||||||
SearchFunc="@SearchCountryCodes" ToStringFunc="@(e=> string.IsNullOrEmpty(e) ? "" : @dataListService.GetLocalizedValue(GuestConsts.DataList_CountryCodes, e))"
|
Label="@LanguageLocale.dto_GuestDocument_Nationality" SearchFunc="@SearchCountryCodes"
|
||||||
SelectValueOnTab="true" AdornmentIcon="@Icons.Material.Filled.Search"
|
ToStringFunc="@(e=> string.IsNullOrEmpty(e) ? "" : @dataListService.GetLocalizedValue(GuestConsts.DataList_CountryCodes, e))"
|
||||||
style="@FieldMarginY" />
|
SelectValueOnTab="true" AdornmentIcon="@Icons.Material.Filled.Search" style="@FieldMarginY"
|
||||||
|
Required />
|
||||||
</MudPaper>
|
</MudPaper>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
<MudItem xs="12" md="6">
|
<MudItem xs="12" md="6">
|
||||||
<MudPaper Class="pa-4" Elevation="3" Height="100%">
|
<MudPaper Class="pa-4" Elevation="3" Height="100%">
|
||||||
<MudText Typo="Typo.subtitle1" Align="Align.Center">@LanguageLocale.control_GuestDocForm_sectionGuest</MudText>
|
<MudText Typo="Typo.subtitle1" Align="Align.Center">
|
||||||
|
@LanguageLocale.control_GuestDocForm_sectionGuest
|
||||||
|
</MudText>
|
||||||
<MudDivider DividerType="DividerType.Middle" Class="mb-4" />
|
<MudDivider DividerType="DividerType.Middle" Class="mb-4" />
|
||||||
|
|
||||||
<MudTextField @bind-Value="Model.Name" For="@(() => Model.Name)"
|
<MudTextField @bind-Value="Model.Name" For="@(() => Model.Name)" Required
|
||||||
Label="@LanguageLocale.dto_GuestDocument_Name"
|
Label="@LanguageLocale.dto_GuestDocument_Name"
|
||||||
OnBlur="@(() => Model.Name = Model.Name?.ToUpper())" />
|
OnBlur="@(() => Model.Name = Model.Name?.ToUpper())" />
|
||||||
<MudTextField @bind-Value="Model.Surname" For="@(() => Model.Surname)"
|
<MudTextField @bind-Value="Model.Surname" For="@(() => Model.Surname)" Required
|
||||||
Label="@LanguageLocale.dto_GuestDocument_Surname"
|
Label="@LanguageLocale.dto_GuestDocument_Surname"
|
||||||
OnBlur="@(() => Model.Surname = Model.Surname?.ToUpper())" />
|
OnBlur="@(() => Model.Surname = Model.Surname?.ToUpper())" />
|
||||||
<MudTextField @bind-Value="Model.Surname2" For="@(() => Model.Surname2)"
|
<MudTextField @bind-Value="Model.Surname2" For="@(() => Model.Surname2)"
|
||||||
@@ -60,11 +68,14 @@
|
|||||||
OnBlur="@(() => Model.Surname2 = Model.Surname2?.ToUpper())" />
|
OnBlur="@(() => Model.Surname2 = Model.Surname2?.ToUpper())" />
|
||||||
|
|
||||||
<MudStack Row style="@FieldMarginY">
|
<MudStack Row style="@FieldMarginY">
|
||||||
<MudDatePicker @bind-Date="Model.BirthDate" For="@(() => Model.BirthDate)" Label="@LanguageLocale.dto_GuestDocument_BirthDate"
|
<MudDatePicker @bind-Date="Model.BirthDate" For="@(() => Model.BirthDate)"
|
||||||
Clearable OpenTo="OpenTo.Year" Editable />
|
Label="@LanguageLocale.dto_GuestDocument_BirthDate" OpenTo="OpenTo.Year" Clearable Required
|
||||||
|
Editable />
|
||||||
|
|
||||||
<MudSelect @bind-Value="Model.Gender" For="@(() => Model.Gender)" Label="@LanguageLocale.dto_GuestDocument_Gender">
|
<MudSelect @bind-Value="Model.Gender" For="@(() => Model.Gender)"
|
||||||
@foreach (string gender in dataListService.GetDataListByName(GuestConsts.DataList_GenderOptions))
|
Label="@LanguageLocale.dto_GuestDocument_Gender">
|
||||||
|
@foreach (string gender in
|
||||||
|
dataListService.GetDataListByName(GuestConsts.DataList_GenderOptions))
|
||||||
{
|
{
|
||||||
<MudSelectItem Value="gender">
|
<MudSelectItem Value="gender">
|
||||||
@dataListService.GetLocalizedValue(GuestConsts.DataList_GenderOptions, gender)
|
@dataListService.GetLocalizedValue(GuestConsts.DataList_GenderOptions, gender)
|
||||||
@@ -77,50 +88,58 @@
|
|||||||
|
|
||||||
<MudItem xs="12" md="6">
|
<MudItem xs="12" md="6">
|
||||||
<MudPaper Class="pa-4" Elevation="3" Height="100%">
|
<MudPaper Class="pa-4" Elevation="3" Height="100%">
|
||||||
<MudText Typo="Typo.subtitle1" Align="Align.Center">@LanguageLocale.control_GuestDocForm_sectionContact</MudText>
|
<MudText Typo="Typo.subtitle1" Align="Align.Center">
|
||||||
|
@LanguageLocale.control_GuestDocForm_sectionContact
|
||||||
|
</MudText>
|
||||||
<MudDivider DividerType="DividerType.Middle" Class="mb-4" />
|
<MudDivider DividerType="DividerType.Middle" Class="mb-4" />
|
||||||
|
|
||||||
<MudStack Row>
|
<MudStack Row>
|
||||||
<MudTextField @bind-Value="Model.PhoneNumber" For="@(() => Model.PhoneNumber)"
|
<MudTextField @bind-Value="Model.PhoneNumber" For="@(() => Model.PhoneNumber)"
|
||||||
Label="@LanguageLocale.dto_GuestDocument_PhoneNumber"
|
Label="@LanguageLocale.dto_GuestDocument_PhoneNumber" InputType="InputType.Telephone" />
|
||||||
InputType="InputType.Telephone" />
|
|
||||||
<MudTextField @bind-Value="Model.EmailAddress" For="@(() => Model.EmailAddress)"
|
<MudTextField @bind-Value="Model.EmailAddress" For="@(() => Model.EmailAddress)"
|
||||||
Label="@LanguageLocale.dto_GuestDocument_EmailAddress"
|
Label="@LanguageLocale.dto_GuestDocument_EmailAddress" InputType="InputType.Email" />
|
||||||
InputType="InputType.Email" />
|
|
||||||
</MudStack>
|
</MudStack>
|
||||||
</MudPaper>
|
</MudPaper>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
|
|
||||||
<MudItem xs="12" md="6">
|
<MudItem xs="12" md="6">
|
||||||
<MudPaper Class="pa-4" Elevation="3" Height="100%">
|
<MudPaper Class="pa-4" Elevation="3" Height="100%">
|
||||||
<MudText Typo="Typo.subtitle1" Align="Align.Center">@LanguageLocale.control_GuestDocForm_sectionAddress</MudText>
|
<MudText Typo="Typo.subtitle1" Align="Align.Center">
|
||||||
|
@LanguageLocale.control_GuestDocForm_sectionAddress
|
||||||
|
</MudText>
|
||||||
<MudDivider DividerType="DividerType.Middle" Class="mb-4" />
|
<MudDivider DividerType="DividerType.Middle" Class="mb-4" />
|
||||||
|
|
||||||
@if (!ReadOnly)
|
@if (!ReadOnly)
|
||||||
{
|
{
|
||||||
<MudButton OnClick="BtnOpenAddressSearchDialog" Variant="Variant.Outlined" FullWidth="true" Class="mb-2">
|
<MudStack Row>
|
||||||
@LanguageLocale.control_GuestDocForm_btnSearchAddress
|
<MudButton OnClick="BtnOpenAddressSearchDialog" Variant="Variant.Outlined" FullWidth="true"
|
||||||
</MudButton>
|
Class="mb-2">
|
||||||
|
@LanguageLocale.control_GuestDocForm_btnSearchAddress
|
||||||
|
</MudButton>
|
||||||
|
<MudIconButton OnClick="BtnSkipAddressSearch" Variant="Variant.Outlined" Disabled="!ReadOnlyAddress"
|
||||||
|
Icon="@Icons.Material.Filled.SkipNext" Class="mb-2" />
|
||||||
|
</MudStack>
|
||||||
}
|
}
|
||||||
|
|
||||||
<MudTextField @bind-Value="Model.Address" For="@(() => Model.Address)"
|
<MudTextField @bind-Value="Model.Address" For="@(() => Model.Address)"
|
||||||
Label="@LanguageLocale.general_address_address" ReadOnly="@ReadOnlyAddress" />
|
Label="@LanguageLocale.general_address_address" ReadOnly="@ReadOnlyAddress" />
|
||||||
<MudStack Row style="@FieldMarginY">
|
<MudStack Row style="@FieldMarginY">
|
||||||
<MudTextField @bind-Value="Model.AddressCity" For="@(() => Model.AddressCity)"
|
<MudTextField @bind-Value="Model.AddressCity" For="@(() => Model.AddressCity)"
|
||||||
Label="@LanguageLocale.general_address_city" ReadOnly="@ReadOnlyAddress" />
|
Label="@LanguageLocale.general_address_city" ReadOnly="@ReadOnlyAddress" />
|
||||||
<MudTextField @bind-Value="Model.AddressProvince" For="@(() => Model.AddressProvince)"
|
<MudTextField @bind-Value="Model.AddressProvince" For="@(() => Model.AddressProvince)"
|
||||||
Label="@LanguageLocale.general_address_province" ReadOnly="@ReadOnlyAddress" />
|
Label="@LanguageLocale.general_address_province" ReadOnly="@ReadOnlyAddress" />
|
||||||
<MudTextField @bind-Value="Model.AddressState" For="@(() => Model.AddressState)"
|
<MudTextField @bind-Value="Model.AddressState" For="@(() => Model.AddressState)"
|
||||||
Label="@LanguageLocale.general_address_state" ReadOnly="@ReadOnlyAddress" />
|
Label="@LanguageLocale.general_address_state" ReadOnly="@ReadOnlyAddress" />
|
||||||
</MudStack>
|
</MudStack>
|
||||||
<MudStack Row style="@FieldMarginY">
|
<MudStack Row style="@FieldMarginY">
|
||||||
<MudAutocomplete T="string" @bind-Value="Model.AddressCountry" For="@(() => Model.AddressCountry)"
|
<MudAutocomplete T="string" @bind-Value="Model.AddressCountry" For="@(() => Model.AddressCountry)"
|
||||||
Label="@LanguageLocale.general_address_country" ReadOnly="@ReadOnlyAddress"
|
Label="@LanguageLocale.general_address_country" ReadOnly="@ReadOnlyAddress"
|
||||||
SearchFunc="@SearchCountryCodes" ToStringFunc="@(e=> string.IsNullOrEmpty(e) ? "" : @dataListService.GetLocalizedValue(GuestConsts.DataList_CountryCodes, e))"
|
SearchFunc="@SearchCountryCodes"
|
||||||
SelectValueOnTab="true" AdornmentIcon="@Icons.Material.Filled.Search" />
|
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)"
|
<MudTextField @bind-Value="Model.ZipCode" For="@(() => Model.ZipCode)"
|
||||||
Label="@LanguageLocale.general_address_zipCode" ReadOnly="@ReadOnlyAddress" />
|
Label="@LanguageLocale.general_address_zipCode" ReadOnly="@ReadOnlyAddress" />
|
||||||
</MudStack>
|
</MudStack>
|
||||||
</MudPaper>
|
</MudPaper>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
@@ -155,7 +174,20 @@
|
|||||||
|
|
||||||
private Dictionary<string, string>? countryDict = null;
|
private Dictionary<string, string>? countryDict = null;
|
||||||
|
|
||||||
private bool isSuportNumberRequired { get => Model?.Nationality == GuestConsts.CountryCode_ESP; }
|
private bool isSuportNumberRequired
|
||||||
|
{
|
||||||
|
get => Model?.DocumentType == GuestConsts.DocumentType_DNI
|
||||||
|
|| Model?.DocumentType == GuestConsts.DocumentType_NIE;
|
||||||
|
}
|
||||||
|
private PatternMask SuportNumberPatternMask
|
||||||
|
{
|
||||||
|
get => Model?.DocumentType switch
|
||||||
|
{
|
||||||
|
GuestConsts.DocumentType_DNI => new PatternMask("aaa000000"),
|
||||||
|
GuestConsts.DocumentType_NIE => new PatternMask("a00000000"),
|
||||||
|
_ => new PatternMask("")
|
||||||
|
};
|
||||||
|
}
|
||||||
private string CreateTimeString
|
private string CreateTimeString
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -193,7 +225,7 @@
|
|||||||
countryDict = new(countryCodeSet.Count);
|
countryDict = new(countryCodeSet.Count);
|
||||||
|
|
||||||
//Init dict.
|
//Init dict.
|
||||||
foreach(string code in dataListService.GetDataListByName(GuestConsts.DataList_CountryCodes))
|
foreach (string code in dataListService.GetDataListByName(GuestConsts.DataList_CountryCodes))
|
||||||
{
|
{
|
||||||
countryDict.Add(code, dataListService.GetLocalizedValue(GuestConsts.DataList_CountryCodes, code));
|
countryDict.Add(code, dataListService.GetLocalizedValue(GuestConsts.DataList_CountryCodes, code));
|
||||||
}
|
}
|
||||||
@@ -237,6 +269,14 @@
|
|||||||
ReadOnlyAddress = ReadOnly;
|
ReadOnlyAddress = ReadOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task BtnSkipAddressSearch()
|
||||||
|
{
|
||||||
|
userMessage.ShowMessage("Address search skipped! Address is editable now", MessageKind.Info);
|
||||||
|
|
||||||
|
//Make Address editable (if the form is editable).
|
||||||
|
ReadOnlyAddress = ReadOnly;
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
+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("20260910093310_GuestDocument_IssueDate_MakeNullable")]
|
||||||
|
partial class GuestDocument_IssueDate_MakeNullable
|
||||||
|
{
|
||||||
|
/// <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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+42
@@ -0,0 +1,42 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Somnia.GuestLog.Infrastructure.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class GuestDocument_IssueDate_MakeNullable : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<DateOnly>(
|
||||||
|
name: "IssueDate",
|
||||||
|
table: "GuestDocument",
|
||||||
|
type: "date",
|
||||||
|
nullable: true,
|
||||||
|
oldClrType: typeof(DateOnly),
|
||||||
|
oldType: "date");
|
||||||
|
|
||||||
|
//Make null any IssueDate column with "default" value:
|
||||||
|
migrationBuilder.Sql("""UPDATE "GuestDocument" SET "IssueDate" = NULL WHERE "IssueDate" = '1970-01-01';""");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
//Set value to all IssueDate null columns.
|
||||||
|
migrationBuilder.Sql("""UPDATE "GuestDocument" SET "IssueDate" = '1970-01-01' WHERE "IssueDate" IS NULL;""");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<DateOnly>(
|
||||||
|
name: "IssueDate",
|
||||||
|
table: "GuestDocument",
|
||||||
|
type: "date",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(DateOnly),
|
||||||
|
oldType: "date",
|
||||||
|
oldNullable: true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -82,7 +82,7 @@ namespace Somnia.GuestLog.Infrastructure.Migrations
|
|||||||
b.Property<bool>("IsLastVersion")
|
b.Property<bool>("IsLastVersion")
|
||||||
.HasColumnType("boolean");
|
.HasColumnType("boolean");
|
||||||
|
|
||||||
b.Property<DateOnly>("IssueDate")
|
b.Property<DateOnly?>("IssueDate")
|
||||||
.HasColumnType("date");
|
.HasColumnType("date");
|
||||||
|
|
||||||
b.Property<string>("Name")
|
b.Property<string>("Name")
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class GuestDocument : BaseEntity
|
|||||||
public required string DocumentType { get; set; }
|
public required string DocumentType { get; set; }
|
||||||
public required string DocumentNum { get; set; }
|
public required string DocumentNum { get; set; }
|
||||||
|
|
||||||
public required DateOnly IssueDate { get; set; }
|
public required DateOnly? IssueDate { get; set; }
|
||||||
public string? SupportNum { get; set; }
|
public string? SupportNum { get; set; }
|
||||||
|
|
||||||
public required string Nationality { get; set; }
|
public required string Nationality { get; set; }
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ internal static class EntityMapping
|
|||||||
Version = entity.Version,
|
Version = entity.Version,
|
||||||
DocumentType = entity.DocumentType,
|
DocumentType = entity.DocumentType,
|
||||||
DocumentNum = entity.DocumentNum,
|
DocumentNum = entity.DocumentNum,
|
||||||
IssueDate = entity.IssueDate.ToDateTime(TimeOnly.MinValue),
|
IssueDate = entity.IssueDate?.ToDateTime(TimeOnly.MinValue) ?? null,
|
||||||
SupportNum = entity.SupportNum,
|
SupportNum = entity.SupportNum,
|
||||||
Nationality = entity.Nationality,
|
Nationality = entity.Nationality,
|
||||||
Name = entity.Name,
|
Name = entity.Name,
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class GuestDocumentEntityService(
|
|||||||
Version = GuestConsts.GuestDocument_FirstVersion,
|
Version = GuestConsts.GuestDocument_FirstVersion,
|
||||||
DocumentType = dto.DocumentType!,
|
DocumentType = dto.DocumentType!,
|
||||||
DocumentNum = dto.DocumentNum!,
|
DocumentNum = dto.DocumentNum!,
|
||||||
IssueDate = DateOnly.FromDateTime(dto.IssueDate!.Value),
|
IssueDate = dto.IssueDate != null ? DateOnly.FromDateTime(dto.IssueDate!.Value) : null,
|
||||||
SupportNum = dto.SupportNum,
|
SupportNum = dto.SupportNum,
|
||||||
Nationality = dto.Nationality!,
|
Nationality = dto.Nationality!,
|
||||||
Name = dto.Name!,
|
Name = dto.Name!,
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ public static partial class RegexUtils
|
|||||||
public static partial Regex RegexNieFormat();
|
public static partial Regex RegexNieFormat();
|
||||||
|
|
||||||
[GeneratedRegex("^[A-Z]{3}[0-9]{6}$")]
|
[GeneratedRegex("^[A-Z]{3}[0-9]{6}$")]
|
||||||
public static partial Regex RegexGuestDocSuportNumber();
|
public static partial Regex RegexGuestDocSupportNumberDNI();
|
||||||
|
[GeneratedRegex("^E[0-9]{8}$")]
|
||||||
|
public static partial Regex RegexGuestDocSupportNumberNIE();
|
||||||
|
|
||||||
[GeneratedRegex(@"^\+?\d{1,4}?[-.\s]?\(?\d{1,3}?\)?[-.\s]?\d{1,4}[-.\s]?\d{1,4}[-.\s]?\d{1,9}$")]
|
[GeneratedRegex(@"^\+?\d{1,4}?[-.\s]?\(?\d{1,3}?\)?[-.\s]?\d{1,4}[-.\s]?\d{1,4}[-.\s]?\d{1,9}$")]
|
||||||
public static partial Regex RegexPhoneNumber();
|
public static partial Regex RegexPhoneNumber();
|
||||||
|
|||||||
@@ -22,14 +22,22 @@ public class GuestDocumentDTOValidator : ValueValidator<GuestDocumentDTO>
|
|||||||
.Length(6, 32);
|
.Length(6, 32);
|
||||||
|
|
||||||
RuleFor(x => x.IssueDate)
|
RuleFor(x => x.IssueDate)
|
||||||
|
.Cascade(CascadeMode.Stop)
|
||||||
.NotEmpty()
|
.NotEmpty()
|
||||||
|
.When(x => x.Nationality != GuestConsts.CountryCode_ESP)
|
||||||
.LessThanOrEqualTo(DateTime.Today);
|
.LessThanOrEqualTo(DateTime.Today);
|
||||||
|
|
||||||
RuleFor(x => x.SupportNum)
|
RuleFor(x => x.SupportNum)
|
||||||
.Cascade(CascadeMode.Stop)
|
.Cascade(CascadeMode.Stop)
|
||||||
.NotEmpty()
|
.NotEmpty()
|
||||||
.Matches(RegexUtils.RegexGuestDocSuportNumber()).WithMessage("Invalid Format. Expected 'AAA000000'.")
|
.Matches(RegexUtils.RegexGuestDocSupportNumberDNI()).WithMessage("Invalid Format for DNI. Expected 'AAA000000'.")
|
||||||
.When(x => x.Nationality == GuestConsts.CountryCode_ESP);
|
.When(x => x.DocumentType == GuestConsts.DocumentType_DNI);
|
||||||
|
|
||||||
|
RuleFor(x => x.SupportNum)
|
||||||
|
.Cascade(CascadeMode.Stop)
|
||||||
|
.NotEmpty()
|
||||||
|
.Matches(RegexUtils.RegexGuestDocSupportNumberNIE()).WithMessage("Invalid Format for NIE. Expected 'E00000000'.")
|
||||||
|
.When(x => x.DocumentType == GuestConsts.DocumentType_NIE);
|
||||||
|
|
||||||
RuleFor(x => x.Name)
|
RuleFor(x => x.Name)
|
||||||
.NotEmpty()
|
.NotEmpty()
|
||||||
|
|||||||
Reference in New Issue
Block a user