@using GWMS.UI.Components
@using GWMS.Data.DatabaseModels
@using System.Security.Claims
@using Microsoft.AspNetCore.Components.Authorization
@using GWMS.UI.Data
@using GWMS.Data.DTO
@using Microsoft.Extensions.Configuration
@inject MessageService AppMService
@inject GWMSDataService DataService
@inject IConfiguration Configuration
@inject IJSRuntime JSRuntime
@if (showSave)
{
}
@code {
private List PlantsList;
private List SuppliersList;
private List TransportersList;
protected WeekPlanModel _currItem = new WeekPlanModel();
protected int _supplierId { get; set; } = 0;
[Parameter]
public WeekPlanModel currItem
{
get
{
return _currItem = null;
}
set
{
_currItem = value;
}
}
protected bool showSave
{
get
{
bool answ = (_currItem.PlantId > 0 && _currItem.SupplierId > 0 && _currItem.TransporterId > 0);
return answ;
}
}
[Parameter]
public EventCallback DataReset { get; set; }
[Parameter]
public EventCallback DataUpdated { get; set; }
[Parameter]
public int SupplierId
{
get
{
return _supplierId;
}
set
{
_supplierId = value;
// condiziono visualizzazione...
var pUpd = Task.Run(async () => await ReloadAllData());
pUpd.Wait();
}
}
private async Task saveUpdate()
{
if (_currItem != null)
{
DataService.WeekPlanUpdateAsync(_currItem);
await DataUpdated.InvokeAsync(1);
}
else
{
Console.WriteLine("User null!");
}
}
private async Task deleteRecord()
{
if (!await JSRuntime.InvokeAsync("confirm", "Sicuro di voler eliminare la consegna selezionata??"))
return;
if (_currItem != null)
{
DataService.WeekPlanDeleteAsync(_currItem);
await DataUpdated.InvokeAsync(1);
}
else
{
Console.WriteLine("User null!");
}
}
private async Task cancelUpdate()
{
await DataReset.InvokeAsync(0);
}
protected override async Task OnInitializedAsync()
{
await ReloadAllData();
}
protected async Task ReloadAllData()
{
PlantsList = await DataService.PlantsListAsync();
SuppliersList = await DataService.SuppliersGetAllAsync();
TransportersList = await DataService.TransportersGetAllAsync();
}
}