91 lines
2.4 KiB
C#
91 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System.Net.Http;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
using Microsoft.AspNetCore.Components.Forms;
|
|
using Microsoft.AspNetCore.Components.Routing;
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
using Microsoft.AspNetCore.Components.Web.Virtualization;
|
|
using Microsoft.JSInterop;
|
|
using REMAN;
|
|
using REMAN.Shared;
|
|
using NLog;
|
|
using NKC.Data.DbModels;
|
|
using REMAN.Data;
|
|
|
|
namespace REMAN.Components
|
|
{
|
|
public partial class RemnantEdit
|
|
{
|
|
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
protected RemnantsModel _currItem = new RemnantsModel();
|
|
|
|
|
|
[Inject]
|
|
protected RDataService DataService { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public RemnantsModel currItem
|
|
{
|
|
get
|
|
{
|
|
return _currItem;
|
|
}
|
|
set
|
|
{
|
|
_currItem = value;
|
|
}
|
|
}
|
|
|
|
[Inject]
|
|
private IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public EventCallback<int> DataReset { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<int> DataUpdated { get; set; }
|
|
|
|
private async Task cancelUpdate()
|
|
{
|
|
await DataReset.InvokeAsync(0);
|
|
}
|
|
|
|
protected string alertMessage = "";
|
|
|
|
private async Task saveUpdate()
|
|
{
|
|
alertMessage = "";
|
|
// verifico duplicato...
|
|
bool duplicato = await DataService.RemnantsIsDupl(currItem);
|
|
if (duplicato)
|
|
{
|
|
alertMessage = "Error: dimension data duplicated, record already available.";
|
|
}
|
|
else
|
|
{
|
|
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Are you sure to create new record?"))
|
|
return;
|
|
|
|
if (_currItem != null)
|
|
{
|
|
await DataService.RemnantsUpsert(currItem, userId);
|
|
await DataUpdated.InvokeAsync(0);
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("Record null!");
|
|
}
|
|
}
|
|
}
|
|
[Parameter]
|
|
public string userId { get; set; } = "";
|
|
|
|
|
|
}
|
|
} |