using k8s.Models; using MagMan.Core; using MagMan.Core.Services; using MagMan.Data.Admin.Services; using MagMan.Data.Tenant.DbModels; using Microsoft.AspNetCore.Components; namespace MagMan.UI.Pages { public partial class ProjectsStatus : 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 => ProjSel == 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.ShowCustomers = true; AppMService.PageName = "Progetti"; AppMService.PageIcon = "fa-solid fa-chart-gantt pr-2"; AppMService.EA_CustomerSel += AppMService_EA_CustomerSel; CustomerID = AppMService.CustomerID; // rileggo dati await ReloadData(); } protected void SaveProj(ProjModel? newRec) { ProjSel = newRec; ProjDbId = newRec != null ? newRec.ProjDbId : 0; } #endregion Protected Methods #region Private Fields private int KeyNum = 0; #endregion Private Fields #region Private Properties private int CustomerID { get; set; } = 0; private bool isLoading { get; set; } = false; private int ProjDbId { get; set; } = 0; private ProjModel? ProjSel { get; set; } = null; #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 } }