SHA256
GuestLog - User message improvements
- Added UserMessageService to have common methods for showing messages and errors to the user. - Added Result record so services can return status on operation error (so it can be shown in the UI messages). - Updated services to use the new Result record. - Updated pages to use the new IUserMessageService.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
@using Somnia.GuestLog.Services;
|
||||
@using Somnia.GuestLog.Validators;
|
||||
|
||||
@inject ISnackbar Snackbar
|
||||
@inject IUserMessageService userMessage
|
||||
@inject IDialogService DialogService
|
||||
@inject NavigationManager Navigation
|
||||
@inject IGuestDocumentService guestDocService
|
||||
@@ -129,26 +129,25 @@
|
||||
bool isFormValid = await _form.ValidateForm();
|
||||
if (!isFormValid)
|
||||
{
|
||||
Snackbar.Add("Invalid Form!", Severity.Error);
|
||||
userMessage.ShowMessage("Invalid Form!", MessageKind.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
GuestDocumentDTO model = _form.Model;
|
||||
|
||||
Snackbar.Add($"Document '{model.DocumentNum}' creating...", Severity.Info);
|
||||
|
||||
//Show Loading dialog...
|
||||
var loadingDialog = await DialogService.ShowAsync<LoadingDialog>();
|
||||
|
||||
bool isCreated = await guestDocService.CreateDocumentAsync(model);
|
||||
if (!isCreated)
|
||||
Result createResult = await guestDocService.CreateDocumentAsync(model);
|
||||
if (!createResult.IsSuccess)
|
||||
{
|
||||
Snackbar.Add($"Error creating Document '{model.DocumentNum}'", Severity.Error);
|
||||
string errorMsg = $"Error creating Document '{model.DocumentNum}'";
|
||||
userMessage.ShowResultWithMessage(createResult, errorMsg);
|
||||
loadingDialog.Close();
|
||||
return;
|
||||
}
|
||||
|
||||
Snackbar.Add($"Document '{model.DocumentNum}' Created!", Severity.Success);
|
||||
userMessage.ShowMessage($"Document '{model.DocumentNum}' Created!", MessageKind.Success);
|
||||
Navigation.NavigateTo(GuestConsts.Page_GuestDocs_List);
|
||||
}
|
||||
|
||||
@@ -156,7 +155,7 @@
|
||||
{
|
||||
if (currentPageMode != ePageMode.alreadyExistDoc)
|
||||
{
|
||||
Snackbar.Add("Invalid operation!", Severity.Error);
|
||||
userMessage.ShowMessage("Invalid operation!", MessageKind.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user