125 lines
2.8 KiB
C#
125 lines
2.8 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using SHERPA.BBM.CORE.DbModels;
|
|
using SHERPA.BBM.UI.Data;
|
|
|
|
namespace SHERPA.BBM.UI.Components
|
|
{
|
|
public partial class BasketEditor
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public BasketsModel Basket
|
|
{
|
|
get
|
|
{
|
|
return _basket;
|
|
}
|
|
|
|
set
|
|
{
|
|
_basket = value;
|
|
}
|
|
}
|
|
|
|
[Parameter]
|
|
public EventCallback<int> DataReset { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<int> DataUpdated { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Fields
|
|
|
|
protected BasketsModel _basket = new BasketsModel();
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected BBM_EFService BBMService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
protected int SelCompanyId
|
|
{
|
|
get
|
|
{
|
|
int answ = 0;
|
|
if (_basket != null)
|
|
{
|
|
answ = _basket.CompanyId;
|
|
}
|
|
|
|
return answ;
|
|
}
|
|
|
|
set
|
|
{
|
|
_basket.CompanyId = value;
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await ReloadAllData();
|
|
}
|
|
|
|
protected async Task ReloadAllData()
|
|
{
|
|
companyList = await BBMService.CompanyGetAll();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private List<CompanyModel> companyList = new List<CompanyModel>();
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Methods
|
|
|
|
private async Task cancelUpdate()
|
|
{
|
|
await DataReset.InvokeAsync(0);
|
|
}
|
|
|
|
private async Task CloneNewYear()
|
|
{
|
|
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Sicuro di voler duplicare il Basket corrente e le trattative aperte sul nuovo anno?"))
|
|
return;
|
|
|
|
/*
|
|
* Da fare... FixMe Todo
|
|
*
|
|
* 1) possibile SOLO SE non ha un basket già associato x nuovo anno?
|
|
* 2) deve cercare le negotiations che sono IsOrdPYR
|
|
*
|
|
* */
|
|
}
|
|
|
|
private async Task saveUpdate()
|
|
{
|
|
if (_basket != null)
|
|
{
|
|
await BBMService.BasketsUpdate(_basket);
|
|
await DataUpdated.InvokeAsync(1);
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("Negotiation null!");
|
|
}
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |