120 lines
2.8 KiB
C#
120 lines
2.8 KiB
C#
using LiMan.DB.DBModels;
|
|
using LiMan.UI.Data;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
using System.Threading.Tasks;
|
|
using System;
|
|
using LiMan.UI.Components;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
namespace LiMan.UI.Components
|
|
{
|
|
public partial class EditRelease
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public ReleaseModel 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 Protected Fields
|
|
|
|
protected ReleaseModel _currItem = new ReleaseModel();
|
|
|
|
#endregion Protected Fields
|
|
|
|
#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 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
|
|
|
|
#region Private Properties
|
|
|
|
[Inject]
|
|
private IJSRuntime JSRuntime { get; set; }
|
|
|
|
[Inject]
|
|
private NavigationManager NavManager { get; set; }
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private async Task DoClose()
|
|
{
|
|
await DataReset.InvokeAsync(0);
|
|
}
|
|
private async Task DoCancel()
|
|
{
|
|
await DataReset.InvokeAsync(0);
|
|
}
|
|
|
|
private async Task DoSave()
|
|
{
|
|
if (_currItem != null)
|
|
{
|
|
await DataService.ReleaseUpsert(_currItem);
|
|
await DataUpdated.InvokeAsync(0);
|
|
}
|
|
else
|
|
{
|
|
Console.WriteLine("Record null!");
|
|
}
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |