SHA256
GuestLog - StayEntry - Initial Implementation
- Added new entity "StayEntry" to log stays of guests. - Added pages for StayEntry management (List and creation). - New DataList for PaymentMethods. - Other general changes and improvements.
This commit is contained in:
@@ -58,7 +58,7 @@
|
||||
<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.page_GuestDocList_showAllElements"
|
||||
<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)">
|
||||
|
||||
@@ -0,0 +1,107 @@
|
||||
@attribute [Route($"{GuestConsts.Page_StayEntry_List}")]
|
||||
|
||||
@using Somnia.GuestLog.Models.DTOs;
|
||||
@using Somnia.GuestLog.Services;
|
||||
|
||||
@inject IStayEntryService StayEntryService
|
||||
@inject NavigationManager Navigation
|
||||
@inject ISnackbar Snackbar
|
||||
@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>
|
||||
|
||||
<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>
|
||||
|
||||
@code {
|
||||
|
||||
private bool _dataLoading = true;
|
||||
private bool _showAllData = false;
|
||||
private const int resultLimit = 200;
|
||||
|
||||
private IEnumerable<StayEntryDTO> stayEntryList = [];
|
||||
|
||||
private MudDataGrid<StayEntryDTO> _dataGrid = 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.GetDtoListAsync();
|
||||
//stayEntryList = await StayEntryService.GetDtoListAsync(filter: filter, limit: dataLimit);
|
||||
|
||||
if (showMsg)
|
||||
{
|
||||
Snackbar.Add("Data loaded from DB", Severity.Info, o => o.VisibleStateDuration = 1000);
|
||||
}
|
||||
_dataLoading = false;
|
||||
}
|
||||
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
private async Task BtnSearchDataAsync()
|
||||
{
|
||||
await LoadDataAsync();
|
||||
}
|
||||
|
||||
private void BtnNewStay()
|
||||
{
|
||||
Navigation.NavigateTo(GuestConsts.Page_StayEntry_New);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
@attribute [Route($"{GuestConsts.Page_StayEntry_New}")]
|
||||
|
||||
@using Somnia.GuestLog.Models.DTOs;
|
||||
@using Somnia.GuestLog.Services;
|
||||
|
||||
|
||||
@inject ISnackbar Snackbar
|
||||
@inject IDialogService DialogService
|
||||
@inject NavigationManager Navigation
|
||||
@inject IStayEntryService 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" />
|
||||
|
||||
@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)
|
||||
{
|
||||
Snackbar.Add("Invalid Form!", Severity.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
var loadingDialog = await DialogService.ShowAsync<LoadingDialog>();
|
||||
|
||||
StayEntryDTO model = _form.GetModel();
|
||||
bool isCreated = await stayService.CreateEntryAsync(model);
|
||||
if (!isCreated)
|
||||
{
|
||||
Snackbar.Add($"Error creating StayEntry", Severity.Error);
|
||||
loadingDialog.Close();
|
||||
return;
|
||||
}
|
||||
|
||||
Snackbar.Add($"StayEntry Created!", Severity.Success);
|
||||
Navigation.NavigateTo(GuestConsts.Page_StayEntry_List);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user