Files
limanapp/LiMan.UI/Components/EditApplicazioniGLS.razor.cs
2021-10-13 19:06:51 +02:00

115 lines
2.7 KiB
C#

using LiMan.GLS.DatabaseModels;
using LiMan.UI.Data;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace LiMan.UI.Components
{
public partial class EditApplicazioniGLS
{
#region Protected Fields
protected AnagApplicazioni _currItem = new AnagApplicazioni();
#endregion Protected Fields
#region Private Properties
[Inject]
private IJSRuntime JSRuntime { get; set; }
[Inject]
private NavigationManager NavManager { get; set; }
#endregion Private Properties
#region Protected Properties
[Inject]
protected LiManDataService 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 AnagApplicazioni 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.ApplicazioniGLSUpdate(_currItem);
await DataUpdated.InvokeAsync(0);
}
else
{
Console.WriteLine("Record null!");
}
}
#endregion Private Methods
#region Protected Methods
/// <summary>
/// Blazor: get query parm from the URL
/// </summary>
/// <param name="parmName"></param>
/// <returns></returns>
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
}
}