98 lines
5.4 KiB
Plaintext
98 lines
5.4 KiB
Plaintext
@attribute [Authorize]
|
|
@page "/management/Eventi"
|
|
@using Microsoft.EntityFrameworkCore
|
|
@using StandManager.Model
|
|
|
|
@rendermode InteractiveServer
|
|
|
|
@inject TooltipService tooltipService
|
|
|
|
<PageTitle>Eventi</PageTitle>
|
|
|
|
<div class="page-wrapper">
|
|
<!-- BEGIN PAGE BODY -->
|
|
<div class="page-body">
|
|
<div class="container-xl">
|
|
<div class="row row-cards">
|
|
<div class="col">
|
|
<!-- Page pre-title -->
|
|
<div class="page-pretitle">Overview</div>
|
|
<h2 class="page-title">Eventi</h2>
|
|
</div>
|
|
<div class="col-auto ms-auto">
|
|
<div class="btn-list">
|
|
<a href="/management/Eventi/Modifica" class="btn btn-primary btn-5 d-none d-sm-inline-block">
|
|
Nuovo evento
|
|
</a>
|
|
</div>
|
|
</div>
|
|
<div class="col-lg-12">
|
|
<div class="card">
|
|
<div class="table-responsive">
|
|
<RadzenDataGrid @ref="eventiGrid" AllowFiltering="true" AllowColumnResize="true" AllowAlternatingRows="false" FilterMode="FilterMode.CheckBoxList" AllowSorting="true" PageSize="25"
|
|
AllowPaging="true" PagerHorizontalAlign="HorizontalAlign.Left" ShowPagingSummary="true"
|
|
Data="@eventi" LogicalFilterOperator="LogicalFilterOperator.Or" SelectionMode="DataGridSelectionMode.Single">
|
|
<Columns>
|
|
<RadzenDataGridColumn Property="@nameof(EventoViewModel.Id)" Filterable="false" Title="ID" Width="200px" TextAlign="TextAlign.Center" />
|
|
<RadzenDataGridColumn Property="@nameof(EventoViewModel.Titolo)" Title="Titolo" Width="250px" />
|
|
<RadzenDataGridColumn Property="@nameof(EventoViewModel.DataDa)" Title="Dal" Width="250px" />
|
|
<RadzenDataGridColumn Property="@nameof(EventoViewModel.DataA)" Title="Al" Width="250px" />
|
|
|
|
<RadzenDataGridColumn Context="evento" Filterable="false" Sortable="false" TextAlign="TextAlign.Right" Width="250px">
|
|
<Template Context="evento">
|
|
<RadzenButton Icon="calendar_clock" ButtonStyle="ButtonStyle.Light" Variant="Variant.Flat" Size="ButtonSize.Medium" class="rz-my-1 rz-ms-1" Click="@(args => SendInvitation(evento))" @onclick:stopPropagation="true" MouseEnter="@(args => ShowTooltip(args, new TooltipOptions() { Text = "Invia invito" }))" />
|
|
<RadzenButton Icon="edit" ButtonStyle="ButtonStyle.Light" Variant="Variant.Flat" Size="ButtonSize.Medium" class="rz-my-1 rz-ms-1" Click="@(args => EditRow(evento))" @onclick:stopPropagation="true" MouseEnter="@(args => ShowTooltip(args, new TooltipOptions() { Text = "Modifica evento" }))" />
|
|
<RadzenButton Icon="delete" ButtonStyle="ButtonStyle.Danger" Variant="Variant.Flat" Size="ButtonSize.Medium" Shade="Shade.Lighter" class="rz-my-1 rz-ms-1" Click="@(args => DeleteRow(evento))" @onclick:stopPropagation="true" MouseEnter="@(args => ShowTooltip(args, new TooltipOptions() { Text = "Rimuovi evento" }))" />
|
|
</Template>
|
|
</RadzenDataGridColumn>
|
|
</Columns>
|
|
</RadzenDataGrid>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@code {
|
|
List<EventoViewModel> eventi;
|
|
RadzenDataGrid<EventoViewModel> eventiGrid;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await base.OnInitializedAsync();
|
|
|
|
eventi = (await _managerService.EventoService.RicercaQueryable(x => x.Eliminato == false)).Select(x => (EventoViewModel)x).ToList();
|
|
}
|
|
|
|
private async Task EditRow(EventoViewModel evento)
|
|
{
|
|
_navManager.NavigateTo($"/management/Eventi/Modifica/{evento.Id}");
|
|
}
|
|
|
|
private async Task DeleteRow(EventoViewModel evento)
|
|
{
|
|
var ok = await _dialogService.Confirm($"Vuoi davvero eliminare l'evento {evento.Titolo}?", "Conferma eliminazione", new ConfirmOptions { OkButtonText = "Sì", CancelButtonText = "No", Width = "400px" });
|
|
|
|
if (ok == true)
|
|
{
|
|
await _managerService.EventoService.Elimina(evento.Id, await MembershipUtils.GetUserId(_auth));
|
|
eventi = (await _managerService.EventoService.RicercaQueryable(x => x.Eliminato == false)).Select(x => (EventoViewModel)x).ToList();
|
|
}
|
|
}
|
|
|
|
private async Task SendInvitation(EventoViewModel evento)
|
|
{
|
|
var ok = await _dialogService.Confirm($"Vuoi davvero invitare i clienti all'evento {evento.Titolo}?", "Conferma invito", new ConfirmOptions { OkButtonText = "Sì", CancelButtonText = "No", Width = "400px" });
|
|
|
|
if (ok == true)
|
|
{
|
|
_dialogService.Close();
|
|
//Invito
|
|
await _dialogService.OpenAsync<Eventi_Inviti>("Inviti", new Dictionary<string, object>() { { "eventoId", evento.Id } });
|
|
}
|
|
}
|
|
|
|
void ShowTooltip(ElementReference elementReference, TooltipOptions options = null) => tooltipService.Open(elementReference, options.Text, options);
|
|
} |