feb6e5c5dc
- Aggiunta gestione storno (btn) - fix clonazione risorse
114 lines
2.9 KiB
C#
114 lines
2.9 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using SHERPA.BBM.CORE.DbModels;
|
|
using SHERPA.BBM.UI.Data;
|
|
|
|
namespace SHERPA.BBM.UI.Components
|
|
{
|
|
public partial class DocsEditor
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public DocsModel currItem
|
|
{
|
|
get
|
|
{
|
|
return _currItem ?? new DocsModel();
|
|
}
|
|
|
|
set
|
|
{
|
|
_currItem = value;
|
|
}
|
|
}
|
|
|
|
[Parameter]
|
|
public EventCallback<int> DataReset { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<int> DataUpdated { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Fields
|
|
|
|
protected DocsModel _currItem = new DocsModel();
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected BBM_EFService BBMService { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected BBM_SelectData SelectData { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await ReloadAllData();
|
|
}
|
|
|
|
protected async Task ReloadAllData()
|
|
{
|
|
BasketList = await BBMService.BasketsGetAsync(1, 0);
|
|
NegotiationList = await BBMService.NegotiationsGetAllAsync();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private List<vBasketsDataModel> BasketList = new List<vBasketsDataModel>();
|
|
private List<NegotiationsModel> NegotiationList = new List<NegotiationsModel>();
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Methods
|
|
|
|
private async Task cancelUpdate()
|
|
{
|
|
await DataReset.InvokeAsync(0);
|
|
}
|
|
|
|
private async Task saveUpdate()
|
|
{
|
|
if (_currItem != null)
|
|
{
|
|
// se è licenza --> attivo!
|
|
if (_currItem.DocType >= BbmDocType.Licenza)
|
|
{
|
|
_currItem.IsActive = true;
|
|
}
|
|
|
|
BBMService.DocsUpdate(_currItem);
|
|
// SE non si tratta di licenza o altro "successivo"
|
|
if (_currItem.DocType != BbmDocType.Licenza && _currItem.DocType != BbmDocType.Storno)
|
|
{
|
|
// aggiorno active
|
|
await BBMService.DocSetActive(_currItem);
|
|
}
|
|
|
|
// SE ho un doc da clonare...
|
|
if (_currItem.DocIdSource > 0)
|
|
{
|
|
// clono ANCHE le resources suo NUOVO elemento
|
|
BBMService.ResourceCloneByDoc(_currItem.DocIdSource, _currItem.DocId, _currItem.DocType);
|
|
}
|
|
|
|
// evento
|
|
await DataUpdated.InvokeAsync(1);
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("Doc null!");
|
|
}
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |