Files
webdoorcreator/WebDoorCreator.UI/Components/Hardware/HardwareNewPanel.razor.cs
T
2023-04-28 10:44:23 +02:00

90 lines
2.5 KiB
C#

using Microsoft.AspNetCore.Components;
using WebDoorCreator.Data.DbModels;
using WebDoorCreator.UI.Data;
namespace WebDoorCreator.UI.Components.Hardware
{
public partial class HardwareNewPanel
{
#region Public Properties
[Parameter]
public int DoorId { get; set; } = 0;
[Parameter]
public EventCallback<DoorOpModel> E_recordUpdate { get; set; }
[Parameter]
public EventCallback<DoorOpModel> E_selTemplate { get; set; }
[Parameter]
public bool HwAdded { get; set; } = false;
[Parameter]
public string HwCode { get; set; } = "";
[Parameter]
public string Lingua { get; set; } = "EN";
#endregion Public Properties
#region Protected Properties
protected List<DoorOpModel>? DoorOpList { get; set; } = null!;
protected int instNum { get; set; } = 1;
[Inject]
protected WebDoorCreatorService WDCService { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
/// <summary>
/// Gestione update da oggetto sottostante
/// </summary>
/// <param name="currItem"></param>
/// <returns></returns>
protected async Task manageUpdate(DoorOpModel currItem)
{
await Task.Delay(1);
// gestione record aggiornato da salvare
#if false
await E_recordUpdate.InvokeAsync(currItem);
#endif
// aggiorna nelle DoorOpList...
if (DoorOpList != null)
{
var item2rem = DoorOpList.Where(x => x.DoorOpId == currItem.DoorOpId).FirstOrDefault();
if (item2rem != null)
{
DoorOpList.Remove(item2rem);
}
await Task.Delay(1);
DoorOpList.Add(currItem);
}
}
protected override async Task OnParametersSetAsync()
{
await ReloadData();
}
#endregion Protected Methods
#region Private Methods
private async Task ReloadData()
{
var ListRecord = await WDCService.DoorOpGetByDoorId(DoorId);
var tempListVal = await WDCService.ListValuesGetAll(HwCode, "Folder");
if (ListRecord != null)
{
DoorOpList = ListRecord.Where(x => (x.DoorId == DoorId) && (x.ObjectId == HwCode)).ToList();
}
}
#endregion Private Methods
}
}