Rimozione
This commit is contained in:
@ -17,7 +17,7 @@
|
||||
<link href="/libs/Fontawesome/css/all.min.css" rel="stylesheet" />
|
||||
<link href="/libs/Fontawesome/css/regular.min.css" rel="stylesheet" />
|
||||
<link rel="icon" type="image/png" href="favicon.png" />
|
||||
<RadzenTheme Theme="material" @rendermode="InteractiveServer" />
|
||||
<RadzenTheme Theme="material" />
|
||||
<HeadOutlet />
|
||||
</head>
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
@using Microsoft.AspNetCore.Authentication
|
||||
@inherits LayoutComponentBase
|
||||
|
||||
<RadzenComponents @rendermode="InteractiveAuto" />
|
||||
<div class="page">
|
||||
<!-- NAV MENU MANAGEMENT -->
|
||||
<header class="navbar navbar-expand-md d-print-none" >
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
@rendermode InteractiveServer
|
||||
|
||||
@inject DialogService DialogService
|
||||
@inject AuthenticationStateProvider auth
|
||||
|
||||
<PageTitle>Utenti</PageTitle>
|
||||
|
||||
@ -40,8 +40,6 @@
|
||||
<Template Context="user">
|
||||
<RadzenButton Icon="edit" ButtonStyle="ButtonStyle.Light" Variant="Variant.Flat" Size="ButtonSize.Medium" class="rz-my-1 rz-ms-1" Click="@(args => EditRow(user))" @onclick:stopPropagation="true" />
|
||||
<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(user))" @onclick:stopPropagation="true" />
|
||||
<RadzenButton Text="Confirm dialog with markup" ButtonStyle="ButtonStyle.Secondary"
|
||||
Click=@(args => DialogService.Confirm(GetMessage(), "MyTitle", new ConfirmOptions() { OkButtonText = "Yes", CancelButtonText = "No" })) />
|
||||
</Template>
|
||||
</RadzenDataGridColumn>
|
||||
</Columns>
|
||||
@ -72,29 +70,12 @@
|
||||
|
||||
private async Task DeleteRow(Utente user)
|
||||
{
|
||||
var confirmationResult = await this.DialogService.Confirm("Are you sure?", "Dialog Title", new ConfirmOptions { OkButtonText = "Yes", CancelButtonText = "No" });
|
||||
if (confirmationResult == true)
|
||||
var ok = await _dialogService.Confirm($"Vuoi davvero eliminare l'utente {user.ToString()}?", "Conferma eliminazione", new ConfirmOptions { OkButtonText = "Sì", CancelButtonText = "No", Width = "400px" });
|
||||
|
||||
if (ok == true)
|
||||
{
|
||||
//Delete logic for id
|
||||
await _managerService.UtenteService.Elimina(user.Id, await MembershipUtils.GetUserId(auth));
|
||||
utenti = await _managerService.UtenteService.RicercaQueryable(x => x.Eliminato == false);
|
||||
}
|
||||
// var ok = await dialog.Confirm($"Vuoi davvero eliminare l'utente {user.ToString()}?", "Conferma eliminazione", new ConfirmOptions { OkButtonText = "Sì", CancelButtonText = "No", Width = "400px" });
|
||||
|
||||
// if (ok == true)
|
||||
// {
|
||||
// // qui fai l’eliminazione vera
|
||||
// //ASP
|
||||
// // se serve:
|
||||
// await InvokeAsync(StateHasChanged);
|
||||
// }
|
||||
}
|
||||
|
||||
RenderFragment GetMessage()
|
||||
{
|
||||
return __builder =>
|
||||
{
|
||||
<text>
|
||||
Are <b>you</b> sure?
|
||||
</text>
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -15,6 +15,9 @@
|
||||
|
||||
@using Radzen
|
||||
@using Radzen.Blazor
|
||||
@using StandManager.Utils
|
||||
|
||||
@inject IManagerService _managerService
|
||||
|
||||
@inject DialogService _dialogService
|
||||
@inject NavigationManager _navManager
|
||||
@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Components.WebAssembly.Server;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Radzen;
|
||||
@ -14,7 +15,8 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
builder.Services.AddRazorComponents()
|
||||
.AddInteractiveServerComponents();
|
||||
.AddInteractiveServerComponents()
|
||||
.AddInteractiveWebAssemblyComponents();
|
||||
|
||||
builder.Services.AddCascadingAuthenticationState();
|
||||
|
||||
@ -90,7 +92,8 @@ app.UseAuthorization();
|
||||
app.UseAntiforgery();
|
||||
|
||||
app.MapRazorComponents<App>()
|
||||
.AddInteractiveServerRenderMode();
|
||||
.AddInteractiveServerRenderMode()
|
||||
.AddInteractiveWebAssemblyRenderMode();
|
||||
|
||||
app.Use(async (context, func) =>
|
||||
{
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.22" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.22" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.22" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.11">
|
||||
|
||||
@ -1,4 +1,6 @@
|
||||
namespace StandManager.Utils;
|
||||
using Microsoft.AspNetCore.Components.Authorization;
|
||||
|
||||
namespace StandManager.Utils;
|
||||
|
||||
public class LayoutState
|
||||
{
|
||||
@ -12,3 +14,14 @@ public class LayoutState
|
||||
OnChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public static class MembershipUtils
|
||||
{
|
||||
public static async Task<Guid> GetUserId(AuthenticationStateProvider auth)
|
||||
{
|
||||
var state = await auth.GetAuthenticationStateAsync();
|
||||
var idClaim = state.User.FindFirst("UserId")?.Value;
|
||||
|
||||
return Guid.Parse(idClaim ?? Guid.Empty.ToString());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user