4fda312aac
- altri metodi tracciati - modifica json x prod - aggiunta Async vari
120 lines
2.8 KiB
C#
120 lines
2.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using GWMS.UI.Data;
|
|
using GWMS.Data.DTO;
|
|
using Microsoft.AspNetCore.Components;
|
|
using System.Threading;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.JSInterop;
|
|
using Microsoft.AspNetCore.Identity;
|
|
|
|
namespace GWMS.UI.Components
|
|
{
|
|
public partial class PlantEditor
|
|
{
|
|
#region Protected Fields
|
|
|
|
protected PlantDTO _currItem = new PlantDTO();
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Private Properties
|
|
|
|
[Inject]
|
|
private IConfiguration Configuration { get; set; }
|
|
|
|
[Inject]
|
|
private IJSRuntime JSRuntime { get; set; }
|
|
|
|
[Inject]
|
|
private NavigationManager NavManager { get; set; }
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected UserManager<IdentityUser> _UserManager { get; set; }
|
|
|
|
[Inject]
|
|
protected GWMSDataService DataService { get; set; }
|
|
|
|
protected bool editAll
|
|
{
|
|
get
|
|
{
|
|
bool answ = false;
|
|
var currMode = GetQueryParm("currMode");
|
|
if (!string.IsNullOrEmpty(currMode))
|
|
{
|
|
answ = currMode.Equals("debug");
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
[Inject]
|
|
protected MessageService MessageService { get; set; }
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public PlantDTO currItem
|
|
{
|
|
get
|
|
{
|
|
return _currItem;
|
|
}
|
|
set
|
|
{
|
|
_currItem = value;
|
|
}
|
|
}
|
|
|
|
[Parameter]
|
|
public EventCallback<int> DataReset { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<int> DataUpdated { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async Task cancelUpdate()
|
|
{
|
|
await DataReset.InvokeAsync(0);
|
|
}
|
|
|
|
private async Task saveUpdate()
|
|
{
|
|
if (_currItem != null)
|
|
{
|
|
await DataService.PlantUpdateAsync(_currItem);
|
|
await DataUpdated.InvokeAsync(0);
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("Order null!");
|
|
}
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
#region Protected Methods
|
|
|
|
// Blazor: get query parm from the URL
|
|
protected string GetQueryParm(string parmName)
|
|
{
|
|
var uriBuilder = new UriBuilder(NavManager.Uri);
|
|
var q = System.Web.HttpUtility.ParseQueryString(uriBuilder.Query);
|
|
return q[parmName] ?? "";
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
}
|
|
} |