Files
lux/Lux.UI/Components/Pages/Resources.razor.cs
Annamaria Sassi afac6d4d62 - Modifica modale per stampa file
- Modifica componente filtro
- Modifica interfaccia risorse e cicli
2026-09-02 14:57:28 +02:00

102 lines
2.5 KiB
C#

using EgwCoreLib.Lux.Data.Services.General;
using EgwCoreLib.Razor;
using Radzen.Blazor.Markdown;
namespace Lux.UI.Components.Pages
{
public partial class Resources
{
#region Protected Methods
protected override Task OnInitializedAsync()
{
return ReloadDataAsync();
}
#endregion Protected Methods
#region Private Fields
private List<ResourceModel> AllRecords = new List<ResourceModel>();
private bool isLoading = false;
private BootstrapModal Modal = new();
private string mTitle = "";
private string mMessage = "";
private BootstrapModal.ModalMode mMode = BootstrapModal.ModalMode.ND;
private Dictionary<bool, string> modalOpt = new Dictionary<bool, string>();
#endregion Private Fields
#region Private Properties
[Inject]
private IResourceService ResService { get; set; } = null!;
private string searchVal { get; set; } = string.Empty;
private string btnResetCss
{
get => string.IsNullOrEmpty(searchVal) ? "btn-outline-secondary" : "btn-primary";
}
private string SearchVal
{
get => searchVal;
set
{
if (searchVal != value)
{
searchVal = value;
}
}
}
#endregion Private Properties
#region Private Methods
private async Task ReloadDataAsync()
{
isLoading = true;
AllRecords = await ResService.GetAllAsync();
isLoading = false;
}
private void ResetSearch()
{
SearchVal = "";
}
private async Task DoAdd()
{
mTitle = "Attenzione";
mMessage = "Confermi di voler aggiungere un nuovo record risorsa?";
mMode = BootstrapModal.ModalMode.Confirm;
modalOpt = new();
modalOpt.Add(true, "Si");
modalOpt.Add(false, "No");
if (!await Modal!.ShowAsync<bool>())
return;
var newRecord = new ResourceModel()
{
Name = $"Nuova Risorsa | {DateTime.Now:yyyy.MM.dd-HH.mm.ss}",
CostDriverID = 1
};
await ResService.UpsertAsync(newRecord);
await ReloadDataAsync();
}
private Task DoDelete(bool args)
{
return ReloadDataAsync();
}
#endregion Private Methods
}
}