Files
magman/MagMan.UI/Components/ItemEdit.razor.cs
T
2024-02-14 15:06:31 +01:00

66 lines
1.5 KiB
C#

using MagMan.Core.Services;
using MagMan.Data.Tenant.DbModels;
using MagMan.Data.Tenant.Services;
using Microsoft.AspNetCore.Components;
namespace MagMan.UI.Components
{
public partial class ItemEdit
{
#region Public Properties
[Parameter]
public RawItemModel? CurrRecord { get; set; } = null;
[Parameter]
public EventCallback<bool> EC_update { get; set; }
[Parameter]
public int KeyNum { get; set; } = 0;
#endregion Public Properties
#region Protected Properties
[Inject]
protected MessageService AppMService { get; set; } = null!;
[Inject]
protected TenantService TService { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected async Task DoCancel()
{
await EC_update.InvokeAsync(true);
}
protected async Task DoSave()
{
bool fatto = false;
await Task.Delay(1);
if (CurrRecord != null)
{
fatto = await TService.ItemUpdate(KeyNum, CurrRecord, userName, true);
}
if (fatto)
{
await EC_update.InvokeAsync(true);
}
}
#endregion Protected Methods
#region Private Properties
private string userName
{
get => AppMService.UserName;
set => AppMService.UserName = value;
}
#endregion Private Properties
}
}