SHA256
GuestLog - GuestDocument pages initial implementation
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
@attribute [Route($"{GuestConsts.Page_GuestDocs_New}")]
|
||||
|
||||
@using Microsoft.EntityFrameworkCore;
|
||||
@using Somnia.GuestLog.Models.DTOs;
|
||||
@using Somnia.GuestLog.Infrastructure;
|
||||
@using Somnia.GuestLog.Services;
|
||||
|
||||
@inject IDbContextFactory<GuestLogContext> contextFactory
|
||||
@inject ISnackbar Snackbar
|
||||
@inject NavigationManager Navigation
|
||||
@inject IGuestDocumentService guestDocService
|
||||
|
||||
|
||||
<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()">
|
||||
Create
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Default" Size="Size.Small"
|
||||
StartIcon="@Icons.Material.Filled.ArrowBack" OnClick="() => BtnReturn()">
|
||||
Return
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
<GuestDocForm @ref="_form" />
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
GuestDocForm _form = null!;
|
||||
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
private void BtnReturn()
|
||||
{
|
||||
Navigation.NavigateTo(GuestConsts.Page_GuestDocs_List);
|
||||
}
|
||||
|
||||
private async Task BtnSaveNewGuest()
|
||||
{
|
||||
bool isFormValid = await _form.ValidateForm();
|
||||
if (!isFormValid)
|
||||
{
|
||||
Snackbar.Add("Invalid Form!", Severity.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
GuestDocumentDTO model = _form.Model;
|
||||
|
||||
Snackbar.Add($"Document '{model.DocumentNum}' creating...", Severity.Info);
|
||||
|
||||
bool isCreated = await guestDocService.CreateDocumentAsync(model);
|
||||
if (!isCreated)
|
||||
{
|
||||
Snackbar.Add($"Error creating Document '{model.DocumentNum}'", Severity.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
Navigation.NavigateTo(GuestConsts.Page_GuestDocs_List);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user