Files
mapo-core/MP.Prog/Components/FileEditor.razor.cs
T
2021-09-07 14:22:24 +02:00

138 lines
3.4 KiB
C#

using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MP.FileData.DatabaseModels;
using MP.Prog.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace MP.Prog.Components
{
public partial class FileEditor : ComponentBase
{
#region Public Fields
public FileModel _currItem = new FileModel();
#endregion Public Fields
#region Protected Properties
[Inject]
protected FileArchDataService DataService { get; set; }
[Inject]
protected IJSRuntime JSRuntime { get; set; }
#endregion Protected Properties
#region Public Properties
[Parameter]
public List<ArticoloModel> ArtList { get; set; }
[Parameter]
public FileModel currItem
{
get
{
return _currItem = null;
}
set
{
_currItem = value;
}
}
[Parameter]
public EventCallback<int> DataReset { get; set; }
[Parameter]
public EventCallback<int> DataUpdated { get; set; }
[Parameter]
public List<MacchinaModel> MacList { get; set; }
#endregion Public Properties
#region Private Methods
private async Task ApproveChange()
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler asccettare la modifica del file selezionato generando una nuova revisione?"))
return;
if (_currItem != null)
{
await DataService.FileApprove(_currItem);
await DataUpdated.InvokeAsync(1);
}
else
{
Console.WriteLine("File null!");
}
}
private async Task cancelUpdate()
{
await DataReset.InvokeAsync(0);
}
private async Task deleteRecord()
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler eliminare il file selezionato??"))
return;
if (_currItem != null)
{
await DataService.FileDelete(_currItem);
await DataUpdated.InvokeAsync(1);
}
else
{
Console.WriteLine("File null!");
}
}
private async Task RejectChange()
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Sicuro di voler eliminare la modifica del file selezionato e sovrascrivere la versione in rete?"))
return;
if (_currItem != null)
{
await DataService.FileReject(_currItem);
await DataUpdated.InvokeAsync(1);
}
else
{
Console.WriteLine("File null!");
}
}
private async Task saveUpdate()
{
if (_currItem != null)
{
await DataService.FileUpdate(_currItem);
await DataUpdated.InvokeAsync(1);
}
else
{
Console.WriteLine("File null!");
}
}
#endregion Private Methods
//protected override async Task OnInitializedAsync()
//{
// await ReloadAllData();
//}
//protected async Task ReloadAllData()
//{
//}
}
}