2b4cad4234
- Inserito filtro in offerte in base allo stato
168 lines
4.7 KiB
C#
168 lines
4.7 KiB
C#
using EgwCoreLib.Razor;
|
|
|
|
namespace Lux.UI.Components.Compo.Contatti
|
|
{
|
|
public partial class DealerMan
|
|
{
|
|
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public EventCallback<DealerModel?> EC_EditReq { get; set; }
|
|
|
|
[Parameter]
|
|
public List<DealerModel> DealerList { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public string SearchVal { get; set; } = null!;
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
if (DealerList != null && DealerList.Count > 0)
|
|
{
|
|
ReloadData();
|
|
UpdateTable();
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private int currPage = 1;
|
|
|
|
private DealerModel? editRecord = null;
|
|
|
|
private bool isLoading = false;
|
|
public List<DealerModel> ListFiltDealer { get; set; } = null!;
|
|
|
|
private List<DealerModel> ListRecords = new List<DealerModel>();
|
|
|
|
private int numRecord = 10;
|
|
|
|
private DealerModel? selRecord = null;
|
|
|
|
private int totalCount = 0;
|
|
|
|
private BootstrapModal Modal = new();
|
|
private string mTitle = "";
|
|
private string mMessage = "";
|
|
private BootstrapModal.ModalMode mMode = BootstrapModal.ModalMode.ND;
|
|
private Dictionary<bool, string> modalOpt = new Dictionary<bool, string>();
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
[Inject]
|
|
private IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private string checkSel(DealerModel curRec)
|
|
{
|
|
return (selRecord != null && curRec.DealerID == selRecord.DealerID) ? "table-info" : "";
|
|
}
|
|
|
|
/// <summary>
|
|
/// Imposta record x eliminazione
|
|
/// </summary>
|
|
/// <param name="selRec"></param>
|
|
private async Task DoDelete(DealerModel selRec)
|
|
{
|
|
mTitle = "Attenzione";
|
|
mMessage = "Sicuro di voler eliminare il record?\n ";
|
|
if (string.IsNullOrEmpty(selRec.CompanyName))
|
|
{
|
|
mMessage = mMessage + $"Dettagli: {selRec.FirstName} | {selRec.LastName} | {selRec.VAT}";
|
|
}
|
|
else
|
|
{
|
|
mMessage = mMessage + $"Dettagli: {selRec.CompanyName} | {selRec.VAT}";
|
|
}
|
|
mMode = BootstrapModal.ModalMode.Confirm;
|
|
modalOpt = new();
|
|
modalOpt.Add(true, "Si");
|
|
modalOpt.Add(false, "No");
|
|
if (!await Modal!.ShowAsync<bool>())
|
|
return;
|
|
|
|
//// esegue eliminazione del record...
|
|
//await CService.DeleteAsync(selRec);
|
|
|
|
editRecord = null;
|
|
selRecord = null;
|
|
ReloadData();
|
|
UpdateTable();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Edit fornitore selezionato
|
|
/// </summary>
|
|
/// <param name="curRec"></param>
|
|
private Task DoEdit(DealerModel curRec)
|
|
{
|
|
editRecord = curRec;
|
|
selRecord = curRec;
|
|
return EC_EditReq.InvokeAsync(editRecord);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Reset selezione
|
|
/// </summary>
|
|
private Task DoReset()
|
|
{
|
|
selRecord = null;
|
|
editRecord = null;
|
|
return EC_EditReq.InvokeAsync(editRecord);
|
|
}
|
|
private void ReloadData()
|
|
{
|
|
isLoading = true;
|
|
ListFiltDealer = DealerList;
|
|
IEnumerable<DealerModel> query = DealerList;
|
|
|
|
if (!string.IsNullOrEmpty(SearchVal) && SearchVal.Length >= 3)
|
|
{
|
|
query = query.Where(x => x.FirstName.Contains(SearchVal, StringComparison.OrdinalIgnoreCase) || x.LastName.Contains(SearchVal, StringComparison.OrdinalIgnoreCase) || x.CompanyName.Contains(SearchVal, StringComparison.OrdinalIgnoreCase));
|
|
}
|
|
// effettuo search
|
|
ListFiltDealer = query.ToList();
|
|
totalCount = ListFiltDealer.Count;
|
|
}
|
|
|
|
private void SaveNumRec(int newNum)
|
|
{
|
|
numRecord = newNum;
|
|
currPage = 1;
|
|
UpdateTable();
|
|
}
|
|
|
|
private void SavePage(int newNum)
|
|
{
|
|
currPage = newNum;
|
|
UpdateTable();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Filtro e paginazione
|
|
/// </summary>
|
|
private void UpdateTable()
|
|
{
|
|
// fix paginazione
|
|
ListRecords = ListFiltDealer
|
|
.Skip(numRecord * (currPage - 1))
|
|
.Take(numRecord)
|
|
.ToList();
|
|
isLoading = false;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |