112 lines
2.8 KiB
C#
112 lines
2.8 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using StockMan.CORE.Data;
|
|
using StockMan.Data.DbModels;
|
|
|
|
namespace StockMan.CORE.Pages
|
|
{
|
|
public partial class Operatori
|
|
{
|
|
#region Public Properties
|
|
|
|
public OperatorModel? currOpr { get; set; } = null;
|
|
public bool isLoading { get; set; } = false;
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Fields
|
|
|
|
protected string _CodExt = "";
|
|
protected string _Cognome = "";
|
|
protected string _Id = "";
|
|
protected string _Nome = "";
|
|
protected List<OperatorModel>? listOprAll = null;
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
protected string CodExt
|
|
{
|
|
get => _CodExt;
|
|
set { _CodExt = value; }
|
|
}
|
|
|
|
protected string Cognome
|
|
{
|
|
get => _Cognome;
|
|
set { _Cognome = value; }
|
|
}
|
|
|
|
protected string Id
|
|
{
|
|
get => _Id;
|
|
set { _Id = value; }
|
|
}
|
|
|
|
[Inject]
|
|
protected NavigationManager NavManager { get; set; } = null!;
|
|
|
|
protected string Nome
|
|
{
|
|
get => _Nome;
|
|
set { _Nome = value; }
|
|
}
|
|
|
|
[Inject]
|
|
protected StockDataService SDService { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected async Task addNewItem()
|
|
{
|
|
OperatorModel currRecToMod = new OperatorModel()
|
|
{
|
|
Id = $"{Nome.Substring(0, 1)}{Cognome.Substring(0, 1)}".ToUpper(),
|
|
CodExt = CodExt,
|
|
LastName = Cognome,
|
|
FirstName = Nome
|
|
};
|
|
var done = await SDService.OperatorAddNew(currRecToMod);
|
|
if (done)
|
|
{
|
|
NavManager.NavigateTo(NavManager.Uri, true);
|
|
}
|
|
}
|
|
|
|
protected async Task ModOpr()
|
|
{
|
|
OperatorModel currRecToMod = new OperatorModel()
|
|
{
|
|
Id = Id,
|
|
CodExt = CodExt,
|
|
LastName = Cognome,
|
|
FirstName = Nome
|
|
};
|
|
var done = await SDService.OperatorMod(currRecToMod);
|
|
if (done)
|
|
{
|
|
NavManager.NavigateTo(NavManager.Uri, true);
|
|
}
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
isLoading = true;
|
|
listOprAll = await SDService.OperatorsGetAll();
|
|
isLoading = false;
|
|
}
|
|
|
|
protected async Task setCurrOpr(OperatorModel currRecToMod)
|
|
{
|
|
await Task.Delay(1);
|
|
Id = currRecToMod.Id;
|
|
CodExt = currRecToMod.CodExt;
|
|
Cognome = currRecToMod.LastName;
|
|
Nome = currRecToMod.FirstName;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
}
|
|
} |