89 lines
2.5 KiB
C#
89 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.Data.Admin;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System.Security.Claims;
|
|
|
|
namespace MagMan.UI.Components
|
|
{
|
|
public partial class CmpClaimEdit
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public List<ClaimRec> Value { get; set; } = new List<ClaimRec>();
|
|
|
|
/// <summary>
|
|
/// Scan result callback method
|
|
/// </summary>
|
|
[Parameter]
|
|
public EventCallback<List<ClaimRec>> ValueChanged { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
// rileggo valori dei dizionari
|
|
await ReloadData();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private const string STD_CLAIM = "None";
|
|
private const string STD_CLAIM_VAL = "0";
|
|
|
|
/// <summary>
|
|
/// Elenco CLAIMS da mostrare durante editing
|
|
/// </summary>
|
|
private List<string> ClaimsList = new List<string>() { STD_CLAIM, "CustomerID" };
|
|
|
|
/// <summary>
|
|
/// Elenco claim ammessi dato tipo
|
|
/// </summary>
|
|
private Dictionary<string, Dictionary<string, string>> ClaimValDict = new Dictionary<string, Dictionary<string, string>>();
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Methods
|
|
|
|
private Dictionary<string, string> ClaimValList(string type)
|
|
{
|
|
Dictionary<string, string> answ = new Dictionary<string, string>();
|
|
if (ClaimValDict.ContainsKey(type))
|
|
{
|
|
answ = ClaimValDict[type];
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
ClaimValDict.Clear();
|
|
// carico Customer
|
|
var customList = await MTService.CustomerGetAll();
|
|
if (customList != null)
|
|
{
|
|
ClaimValDict.Add("CustomerID", customList.ToDictionary(x => $"{x.CustomerID}", x => x.Name));
|
|
}
|
|
// eventuali altri valori...
|
|
}
|
|
|
|
protected void Remove(ClaimRec item2del)
|
|
{
|
|
Value.Remove(item2del);
|
|
}
|
|
|
|
protected void AddNew()
|
|
{
|
|
int idx = Value.Count();
|
|
Value.Add(new ClaimRec(STD_CLAIM, STD_CLAIM_VAL, idx++));
|
|
}
|
|
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |