64 lines
1.6 KiB
C#
64 lines
1.6 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using MP.TaskMan.Models;
|
|
using MP.TaskMan.Services;
|
|
|
|
namespace MP.TaskMan
|
|
{
|
|
public partial class TaskEdit
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public TaskListModel? CurrRecord { get; set; } = null;
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> EC_update { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
protected int oldGroup = 0;
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
oldGroup = CurrRecord != null ? CurrRecord.Group : 0;
|
|
}
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected TaskService TService { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected async Task doCancel()
|
|
{
|
|
await EC_update.InvokeAsync(false);
|
|
}
|
|
|
|
protected async Task doSave()
|
|
{
|
|
isProcessing = true;
|
|
bool fatto = false;
|
|
await Task.Delay(1);
|
|
if (CurrRecord != null)
|
|
{
|
|
fatto = await TService.TaskListUpsert(CurrRecord);
|
|
// se cambiato gruppo chiamo reorg gruppo old/new...
|
|
if (CurrRecord.Group != oldGroup)
|
|
{
|
|
await TService.TaskListReorder(oldGroup);
|
|
await TService.TaskListReorder(CurrRecord.Group);
|
|
oldGroup = CurrRecord.Group;
|
|
}
|
|
}
|
|
isProcessing = false;
|
|
await EC_update.InvokeAsync(fatto);
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
private bool isProcessing = false;
|
|
}
|
|
} |