49 lines
1.3 KiB
Plaintext
49 lines
1.3 KiB
Plaintext
@using CORE.Data.DbModels
|
|
@using UI.Data
|
|
@inject GpwDataService GDataServ
|
|
@inject MessageService AppMServ
|
|
|
|
<button @onclick="() => AddNew()" class="px-1 text-center btn btn-lg btn-outline-success">
|
|
<i class="fas fa-plus-circle"></i>
|
|
</button>
|
|
|
|
@code {
|
|
|
|
|
|
[Parameter]
|
|
public DateTime InizioPer { get; set; } = DateTime.Today.AddHours(8);
|
|
|
|
[Parameter]
|
|
public int IdxDip { get; set; } = 0;
|
|
|
|
[Parameter]
|
|
public EventCallback<RegAttivitaModel> NewItemCreated { get; set; }
|
|
|
|
/// <summary>
|
|
/// Indico item selezionato
|
|
/// </summary>
|
|
protected async void AddNew()
|
|
{
|
|
RegAttivitaModel newItem = new RegAttivitaModel();
|
|
TimeSpan durata = new TimeSpan(1,0,0);
|
|
// se ho un record clonato parto da quello...
|
|
if (AppMServ.clonedRA != null)
|
|
{
|
|
newItem = AppMServ.clonedRA;
|
|
}
|
|
else
|
|
{
|
|
// recupero ultima fase x utente...
|
|
newItem = await GDataServ.RegAttLastByDip(1);
|
|
}
|
|
durata = newItem.Durata;
|
|
newItem.IdxRa = 0;
|
|
newItem.Inizio = InizioPer;
|
|
newItem.Fine = InizioPer.AddMinutes(durata.TotalMinutes);
|
|
// salvo in AppMS
|
|
AppMServ.recordRA = newItem;
|
|
await NewItemCreated.InvokeAsync(newItem);
|
|
}
|
|
|
|
}
|