SHA256
GuestLog - GuestDocument fixes & improvements:
- Use GuestDocument Details page to see details. - Added GuestDocument stays in details page. Other minor changes: - Updated validators to use ValueValidator base class. - Changed Snackbar settings to show them better. - Added Empty Debug page to test things. This page wont be updated in git, all test must be local-only.
This commit is contained in:
+7
-7
@@ -26,7 +26,7 @@
|
|||||||
}
|
}
|
||||||
</MudSelect>
|
</MudSelect>
|
||||||
<MudTextField @bind-Value="Model.DocumentNum" For="@(() => Model.DocumentNum)" Label="@LanguageLocale.dto_GuestDocument_DocumentNum"
|
<MudTextField @bind-Value="Model.DocumentNum" For="@(() => Model.DocumentNum)" Label="@LanguageLocale.dto_GuestDocument_DocumentNum"
|
||||||
Immediate="true" Required ReadOnly="@ReadOnlyDocId" />
|
Required ReadOnly="@ReadOnlyDocId" />
|
||||||
</MudStack>
|
</MudStack>
|
||||||
|
|
||||||
<MudStack Row style="@FieldMarginY">
|
<MudStack Row style="@FieldMarginY">
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
Clearable OpenTo="OpenTo.Year" Editable />
|
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)" Label="@LanguageLocale.dto_GuestDocument_SupportNum"
|
||||||
Immediate="true" Required="@isSuportNumberRequired" Mask="@(new PatternMask("aaa000000"))"
|
Required="@isSuportNumberRequired" Mask="@(new PatternMask("aaa000000"))"
|
||||||
OnBlur="@(() => Model.SupportNum = Model.SupportNum?.ToUpper())" />
|
OnBlur="@(() => Model.SupportNum = Model.SupportNum?.ToUpper())" />
|
||||||
</MudStack>
|
</MudStack>
|
||||||
|
|
||||||
@@ -51,13 +51,13 @@
|
|||||||
|
|
||||||
<MudTextField @bind-Value="Model.Name" For="@(() => Model.Name)"
|
<MudTextField @bind-Value="Model.Name" For="@(() => Model.Name)"
|
||||||
Label="@LanguageLocale.dto_GuestDocument_Name"
|
Label="@LanguageLocale.dto_GuestDocument_Name"
|
||||||
Immediate="true" 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)"
|
||||||
Label="@LanguageLocale.dto_GuestDocument_Surname"
|
Label="@LanguageLocale.dto_GuestDocument_Surname"
|
||||||
Immediate="true" 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)"
|
||||||
Label="@LanguageLocale.dto_GuestDocument_Surname2"
|
Label="@LanguageLocale.dto_GuestDocument_Surname2"
|
||||||
Immediate="true" 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)" Label="@LanguageLocale.dto_GuestDocument_BirthDate"
|
||||||
@@ -83,10 +83,10 @@
|
|||||||
<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" Immediate="true" />
|
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" Immediate="true" />
|
InputType="InputType.Email" />
|
||||||
</MudStack>
|
</MudStack>
|
||||||
</MudPaper>
|
</MudPaper>
|
||||||
</MudItem>
|
</MudItem>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
@page "/debug/empty"
|
||||||
|
|
||||||
|
|
||||||
|
@inject ILogger<Empty> logger;
|
||||||
|
@inject ISnackbar Snackbar
|
||||||
|
@inject IDialogService DialogService
|
||||||
|
|
||||||
|
<PageTitle>DEBUG - Empty</PageTitle>
|
||||||
|
|
||||||
|
<MudText Typo="Typo.h3" GutterBottom="true" Class="mt-2">Empty Page for Debug</MudText>
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
|
||||||
|
}
|
||||||
@@ -7,9 +7,7 @@
|
|||||||
@inject IDialogService DialogService
|
@inject IDialogService DialogService
|
||||||
@inject NavigationManager Navigation
|
@inject NavigationManager Navigation
|
||||||
@inject IGuestDocumentService guestDocService
|
@inject IGuestDocumentService guestDocService
|
||||||
|
@inject IStayEntryService stayService
|
||||||
|
|
||||||
@inject FluentValidation.IValidator<GuestDocIdDTO> docIdValidator;
|
|
||||||
|
|
||||||
|
|
||||||
<PageTitle>Somnia - Guest Docs - Details</PageTitle>
|
<PageTitle>Somnia - Guest Docs - Details</PageTitle>
|
||||||
@@ -17,8 +15,8 @@
|
|||||||
<MudStack Row="true" Class="my-4">
|
<MudStack Row="true" Class="my-4">
|
||||||
<MudText Typo="Typo.h4" GutterBottom="true">Guest Document - "@docId"</MudText>
|
<MudText Typo="Typo.h4" GutterBottom="true">Guest Document - "@docId"</MudText>
|
||||||
<MudSpacer />
|
<MudSpacer />
|
||||||
<MudButton Variant="Variant.Filled" Color="Color.Success" Size="Size.Small" StartIcon="@Icons.Material.Filled.Add"
|
<MudButton Variant="Variant.Filled" Color="Color.Success" Size="Size.Small" StartIcon="@Icons.Material.Filled.Edit"
|
||||||
OnClick="() => BtnEdit()">
|
OnClick="() => BtnEdit()" Disabled>
|
||||||
@LanguageLocale.general_btnEdit
|
@LanguageLocale.general_btnEdit
|
||||||
</MudButton>
|
</MudButton>
|
||||||
<MudButton Variant="Variant.Filled" Color="Color.Default" Size="Size.Small"
|
<MudButton Variant="Variant.Filled" Color="Color.Default" Size="Size.Small"
|
||||||
@@ -29,7 +27,46 @@
|
|||||||
|
|
||||||
@if (documentModel is not null)
|
@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" />
|
<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>
|
||||||
|
</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>
|
||||||
|
</RowTemplate>
|
||||||
|
<NoRecordsContent>
|
||||||
|
<MudText>@LanguageLocale.general_noResults</MudText>
|
||||||
|
</NoRecordsContent>
|
||||||
|
<LoadingContent>
|
||||||
|
<MudSkeleton Height="50px" Class="mx-4" />
|
||||||
|
</LoadingContent>
|
||||||
|
</MudTable>
|
||||||
|
</MudTabPanel>
|
||||||
|
|
||||||
|
</MudTabs>
|
||||||
}
|
}
|
||||||
|
|
||||||
@code {
|
@code {
|
||||||
@@ -42,6 +79,10 @@
|
|||||||
GuestDocumentDTO? documentModel = null;
|
GuestDocumentDTO? documentModel = null;
|
||||||
|
|
||||||
|
|
||||||
|
IEnumerable<StayEntryDTO> guestStayList = [];
|
||||||
|
bool guestStaysLoading = true;
|
||||||
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
protected override async Task OnInitializedAsync()
|
||||||
{
|
{
|
||||||
if (docId is null)
|
if (docId is null)
|
||||||
@@ -78,4 +119,22 @@
|
|||||||
{
|
{
|
||||||
Navigation.NavigateTo(GuestConsts.Page_GuestDocs_List);
|
Navigation.NavigateTo(GuestConsts.Page_GuestDocs_List);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task LoadTabGuestStays()
|
||||||
|
{
|
||||||
|
//Only load when there is no data.
|
||||||
|
if (guestStayList.Count() > 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (documentModel is null || documentModel.DocumentType is null || documentModel.DocumentNum is null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
guestStaysLoading = true;
|
||||||
|
guestStayList = await stayService.GetStaysWithGuest(documentModel.DocumentType, documentModel.DocumentNum);
|
||||||
|
guestStaysLoading = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
<MudText Typo="Typo.h4" GutterBottom="true">@LanguageLocale.page_GuestDocList_pageTitle</MudText>
|
<MudText Typo="Typo.h4" GutterBottom="true">@LanguageLocale.page_GuestDocList_pageTitle</MudText>
|
||||||
<MudSpacer />
|
<MudSpacer />
|
||||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Size="Size.Small"
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" Size="Size.Small"
|
||||||
StartIcon="@Icons.Material.Filled.Search" OnClick="() => SearchDataAsync()">
|
StartIcon="@Icons.Material.Filled.Search" OnClick="() => BtnSearchDataAsync()">
|
||||||
@LanguageLocale.general_btnSearch
|
@LanguageLocale.general_btnSearch
|
||||||
</MudButton>
|
</MudButton>
|
||||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Size="Size.Small" StartIcon="@Icons.Material.Filled.Add"
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" Size="Size.Small" StartIcon="@Icons.Material.Filled.Add"
|
||||||
@@ -26,31 +26,7 @@
|
|||||||
</MudStack>
|
</MudStack>
|
||||||
|
|
||||||
<MudPaper Class="pa-4 my-4" Elevation="2" Height="100%">
|
<MudPaper Class="pa-4 my-4" Elevation="2" Height="100%">
|
||||||
<MudForm Model="@docFilter">
|
<GuestDocumentFilterForm @bind-Filter="docFilter" />
|
||||||
<MudStack Row Breakpoint="Breakpoint.LgAndDown" StretchItems="StretchItems.All">
|
|
||||||
<MudStack Row style="margin-block: 0.2em;">
|
|
||||||
<MudSelect @bind-Value="docFilter.DocumentType" For="@(() => docFilter.DocumentType)"
|
|
||||||
Label="@LanguageLocale.dto_GuestDocument_DocumentType">
|
|
||||||
@foreach (string docType in dataListService.GetDataListByName(GuestConsts.DataList_DocumentTypes))
|
|
||||||
{
|
|
||||||
<MudSelectItem Value="docType">
|
|
||||||
@dataListService.GetLocalizedValue(GuestConsts.DataList_DocumentTypes, docType)
|
|
||||||
</MudSelectItem>
|
|
||||||
}
|
|
||||||
</MudSelect>
|
|
||||||
<MudTextField @bind-Value="docFilter.DocumentNumber" For="@(() => docFilter.DocumentNumber)"
|
|
||||||
Label="@LanguageLocale.dto_GuestDocument_DocumentNum" />
|
|
||||||
</MudStack>
|
|
||||||
<MudStack Row style="margin-block: 0.2em;">
|
|
||||||
<MudTextField @bind-Value="docFilter.Name" For="@(() => docFilter.Name)"
|
|
||||||
Label="@LanguageLocale.dto_GuestDocument_Name"
|
|
||||||
HelperText="@LanguageLocale.general_wildcardHelperText" HelperTextOnFocus="true" />
|
|
||||||
<MudTextField @bind-Value="docFilter.Surname" For="@(() => docFilter.Surname)"
|
|
||||||
Label="@LanguageLocale.dto_GuestDocument_Surname"
|
|
||||||
HelperText="@LanguageLocale.general_wildcardHelperText" HelperTextOnFocus="true" />
|
|
||||||
</MudStack>
|
|
||||||
</MudStack>
|
|
||||||
</MudForm>
|
|
||||||
</MudPaper>
|
</MudPaper>
|
||||||
|
|
||||||
<MudDataGrid @ref="_dataGrid" T="GuestDocumentDTO" Items="@guestDocList" Loading="@_dataLoading" ReadOnly="true"
|
<MudDataGrid @ref="_dataGrid" T="GuestDocumentDTO" Items="@guestDocList" Loading="@_dataLoading" ReadOnly="true"
|
||||||
@@ -126,14 +102,6 @@
|
|||||||
|
|
||||||
#region Data Loading
|
#region Data Loading
|
||||||
|
|
||||||
private async Task SearchDataAsync()
|
|
||||||
{
|
|
||||||
docFilter.Name = docFilter.Name?.ToUpper();
|
|
||||||
docFilter.Surname = docFilter.Surname?.ToUpper();
|
|
||||||
|
|
||||||
await LoadDataAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task LoadDataAsync(bool showMsg = true)
|
private async Task LoadDataAsync(bool showMsg = true)
|
||||||
{
|
{
|
||||||
_dataLoading = true;
|
_dataLoading = true;
|
||||||
@@ -152,23 +120,27 @@
|
|||||||
|
|
||||||
#region Event Handlers
|
#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)
|
private async Task BtnConfigureColumnsClick(MouseEventArgs args)
|
||||||
{
|
{
|
||||||
_dataGrid.ShowColumnsPanel(args);
|
_dataGrid.ShowColumnsPanel(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private async Task BtnViewDetails(GuestDocumentDTO item)
|
private async Task BtnViewDetails(GuestDocumentDTO item)
|
||||||
{
|
{
|
||||||
var parameters =
|
GuestDocIdDTO idDto = GuestDocIdDTO.BuildFromDto(item) ?? throw new InvalidOperationException();
|
||||||
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);
|
string itemId = GuestDocIdDTO.EncodeAsString(idDto);
|
||||||
|
string uri = GuestConsts.Page_GuestDocs_Detail.Replace(GuestConsts.Page_GuestDocs_Detail_Param_DocId, itemId);
|
||||||
|
Navigation.NavigateTo(uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task BtnDeleteItem(GuestDocumentDTO item)
|
private async Task BtnDeleteItem(GuestDocumentDTO item)
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ public static class GuestConsts
|
|||||||
|
|
||||||
public const string Page_GuestDocs_List = "/guest-documents";
|
public const string Page_GuestDocs_List = "/guest-documents";
|
||||||
public const string Page_GuestDocs_New = "/guest-documents/new";
|
public const string Page_GuestDocs_New = "/guest-documents/new";
|
||||||
public const string Page_GuestDocs_Detail = "/guest-documents/d/{docId}";
|
public const string Page_GuestDocs_Detail = $"/guest-documents/d/{Page_GuestDocs_Detail_Param_DocId}";
|
||||||
|
public const string Page_GuestDocs_Detail_Param_DocId = "{docId}";
|
||||||
|
|
||||||
public const string Page_StayEntry_List = "/stayEntries";
|
public const string Page_StayEntry_List = "/stayEntries";
|
||||||
public const string Page_StayEntry_New = "/stayEntries/new";
|
public const string Page_StayEntry_New = "/stayEntries/new";
|
||||||
|
|||||||
@@ -25,4 +25,18 @@ public class GuestDocIdDTO
|
|||||||
DocumentNum = parts[1]
|
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
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,13 @@ builder.Services.AddDbContextFactory<GuestLogContext>(options =>
|
|||||||
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
|
builder.Services.AddDatabaseDeveloperPageExceptionFilter();
|
||||||
|
|
||||||
// Add MudBlazor services
|
// Add MudBlazor services
|
||||||
builder.Services.AddMudServices();
|
builder.Services.AddMudServices(c =>
|
||||||
|
{
|
||||||
|
c.SnackbarConfiguration.PositionClass = MudBlazor.Defaults.Classes.Position.TopCenter;
|
||||||
|
c.SnackbarConfiguration.ShowTransitionDuration = 300;
|
||||||
|
c.SnackbarConfiguration.HideTransitionDuration = 500;
|
||||||
|
c.SnackbarConfiguration.VisibleStateDuration = 10000;
|
||||||
|
});
|
||||||
|
|
||||||
// Add components services to the container.
|
// Add components services to the container.
|
||||||
builder.Services.AddRazorComponents()
|
builder.Services.AddRazorComponents()
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace Somnia.GuestLog.Validators;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validator for GuestDocumentDTO which contains multiple rules and can be shared with the back end API
|
/// Validator for GuestDocumentDTO which contains multiple rules and can be shared with the back end API
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GuestDocIdDTOValidator : AbstractValidator<GuestDocIdDTO>
|
public class GuestDocIdDTOValidator : ValueValidator<GuestDocIdDTO>
|
||||||
{
|
{
|
||||||
public GuestDocIdDTOValidator(IDataListService dataListService)
|
public GuestDocIdDTOValidator(IDataListService dataListService)
|
||||||
{
|
{
|
||||||
@@ -34,11 +34,4 @@ public class GuestDocIdDTOValidator : AbstractValidator<GuestDocIdDTO>
|
|||||||
.WithMessage("Invalid NIE")
|
.WithMessage("Invalid NIE")
|
||||||
.When(x => x.DocumentType == GuestConsts.DocumentType_NIE);
|
.When(x => x.DocumentType == GuestConsts.DocumentType_NIE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
|
||||||
{
|
|
||||||
var result = await ValidateAsync(ValidationContext<GuestDocIdDTO>.CreateWithOptions((GuestDocIdDTO)model, x =>
|
|
||||||
x.IncludeProperties(propertyName)));
|
|
||||||
return result.IsValid ? [] : result.Errors.Select(e => e.ErrorMessage);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace Somnia.GuestLog.Validators;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Validator for GuestDocumentDTO which contains multiple rules and can be shared with the back end API
|
/// Validator for GuestDocumentDTO which contains multiple rules and can be shared with the back end API
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GuestDocumentDTOValidator : AbstractValidator<GuestDocumentDTO>
|
public class GuestDocumentDTOValidator : ValueValidator<GuestDocumentDTO>
|
||||||
{
|
{
|
||||||
public GuestDocumentDTOValidator(IDataListService dataListService)
|
public GuestDocumentDTOValidator(IDataListService dataListService)
|
||||||
{
|
{
|
||||||
@@ -82,11 +82,4 @@ public class GuestDocumentDTOValidator : AbstractValidator<GuestDocumentDTO>
|
|||||||
// RuleForEach(x => x.OrderDetails)
|
// RuleForEach(x => x.OrderDetails)
|
||||||
// .SetValidator(new OrderDetailsModelFluentValidator());
|
// .SetValidator(new OrderDetailsModelFluentValidator());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Func<object, string, Task<IEnumerable<string>>> ValidateValue => async (model, propertyName) =>
|
|
||||||
{
|
|
||||||
var result = await ValidateAsync(ValidationContext<GuestDocumentDTO>.CreateWithOptions((GuestDocumentDTO)model, x =>
|
|
||||||
x.IncludeProperties(propertyName)));
|
|
||||||
return result.IsValid ? [] : result.Errors.Select(e => e.ErrorMessage);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user