Files
magman/MagMan.UI/Pages/MachineStatus.razor.cs
2024-06-29 11:55:15 +02:00

96 lines
2.5 KiB
C#

// Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this
// file to you under the MIT license.
using MagMan.Core.Services;
using MagMan.Data.Admin.Services;
using MagMan.Data.Tenant.DbModels;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Components;
namespace MagMan.UI.Pages
{
public partial class MachineStatus : IDisposable
{
#region Public Methods
public void Dispose()
{
AppMService.EA_CustomerSel -= AppMService_EA_CustomerSel;
}
#endregion Public Methods
#region Protected Fields
protected int nKey = 0;
#endregion Protected Fields
#region Protected Properties
[Inject]
protected MessageService AppMService { get; set; } = null!;
protected string mainCss
{
get => MaterialSel == null ? "col-12" : "col-6 small";
}
[Inject]
protected MTAdminService MTService { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected override async Task OnInitializedAsync()
{
AppMService.ShowSearch = true;
AppMService.PageName = "Stato Impianti";
AppMService.PageIcon = "fa-solid fa-screwdriver-wrench pr-2";
AppMService.EA_CustomerSel += AppMService_EA_CustomerSel;
CustomerID = AppMService.CustomerID;
// rileggo dati
await ReloadData();
}
protected void SaveMat(MaterialModel? newMat)
{
MaterialSel = newMat;
}
#endregion Protected Methods
#region Private Fields
private int KeyNum = 0;
private MaterialModel? MaterialSel = null;
#endregion Private Fields
#region Private Properties
private int CustomerID { get; set; } = 0;
private bool isLoading { get; set; } = false;
#endregion Private Properties
#region Private Methods
private async void AppMService_EA_CustomerSel()
{
CustomerID = AppMService.CustomerID;
await Task.Delay(10);
await ReloadData();
await InvokeAsync(StateHasChanged);
}
private async Task ReloadData()
{
isLoading = true;
nKey = await MTService.MainKeyByCustomer(CustomerID);
isLoading = false;
}
#endregion Private Methods
}
}