Files
SteUP_Dotnet/SteUp.Shared/Components/SingleElements/Card/SchedaCard.razor

66 lines
2.4 KiB
Plaintext

@using SteUp.Shared.Components.Layout.Overlay
@using SteUp.Shared.Components.SingleElements.MessageBox
@using SteUp.Shared.Core.Entities
@using SteUp.Shared.Core.Interface.LocalDb
@inject IIspezioniService IspezioniService
@inject IDialogService Dialog
<div class="scheda-card">
<div class="scheda-body-section">
<div class="title-section">
<MudText Class="scheda-title" Typo="Typo.subtitle1">
<b>@Scheda.ActivityTypeId</b>
</MudText>
<div class="sub-info-section">
<MudChip T="string" Icon="@Icons.Material.Rounded.PhotoCamera" Size="Size.Small" Color="Color.Default">
0
</MudChip>
<MudChip T="string" Icon="@Icons.Material.Rounded.QrCode2" Size="Size.Small" Color="Color.Default">
0
</MudChip>
</div>
</div>
<div class="scheda-card-action">
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Rounded.Edit"
Color="Color.Info" Size="Size.Small" OnClick="@UpdateScheda">
Modifica
</MudButton>
<MudButton Variant="Variant.Filled" StartIcon="@Icons.Material.Rounded.Delete"
Color="Color.Error" Size="Size.Small" OnClick="@DeleteScheda">
Cancella
</MudButton>
</div>
</div>
</div>
<ConfirmDeleteMessageBox @ref="_deleteMessageBox" Message="Confermi la cancellazione della scheda corrente?"/>
@code{
[Parameter] public string CodMdep { get; set; } = string.Empty;
[Parameter] public DateOnly Data { get; set; }
[Parameter] public required Scheda Scheda { get; set; }
[Parameter] public EventCallback<Scheda> OnSchedaModified { get; set; }
[Parameter] public EventCallback<Scheda> OnSchedaDeleted { get; set; }
private ConfirmDeleteMessageBox _deleteMessageBox = null!;
private async Task UpdateScheda()
{
var modal = await ModalHelper.OpenFormScheda(Dialog, CodMdep, Data, Scheda);
if (modal is { Canceled: false, Data: Scheda scheda }) await OnSchedaModified.InvokeAsync(scheda);
}
private async Task DeleteScheda()
{
var result = await _deleteMessageBox.ShowAsync();
if (result is true)
{
var deleteScheda = await IspezioniService.DeleteSchedaAsync(Scheda.Id);
if (deleteScheda) await OnSchedaDeleted.InvokeAsync(Scheda);
}
}
}