diff --git a/StandManager/Components/App.razor b/StandManager/Components/App.razor
index 380d5b6..a75302c 100644
--- a/StandManager/Components/App.razor
+++ b/StandManager/Components/App.razor
@@ -17,7 +17,7 @@
-
+
diff --git a/StandManager/Components/Layout/MainLayout.razor b/StandManager/Components/Layout/MainLayout.razor
index ab795c3..ada7de7 100644
--- a/StandManager/Components/Layout/MainLayout.razor
+++ b/StandManager/Components/Layout/MainLayout.razor
@@ -1,6 +1,6 @@
@using Microsoft.AspNetCore.Authentication
@inherits LayoutComponentBase
-
+
diff --git a/StandManager/Components/Pages/Management/Utenti.razor b/StandManager/Components/Pages/Management/Utenti.razor
index 965767d..db11c00 100644
--- a/StandManager/Components/Pages/Management/Utenti.razor
+++ b/StandManager/Components/Pages/Management/Utenti.razor
@@ -3,7 +3,7 @@
@rendermode InteractiveServer
-@inject DialogService DialogService
+@inject AuthenticationStateProvider auth
Utenti
@@ -40,8 +40,6 @@
- DialogService.Confirm(GetMessage(), "MyTitle", new ConfirmOptions() { OkButtonText = "Yes", CancelButtonText = "No" })) />
@@ -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 =>
- {
-
- Are you sure?
-
- };
}
}
diff --git a/StandManager/Components/_Imports.razor b/StandManager/Components/_Imports.razor
index 3f668d8..8c09655 100644
--- a/StandManager/Components/_Imports.razor
+++ b/StandManager/Components/_Imports.razor
@@ -15,6 +15,9 @@
@using Radzen
@using Radzen.Blazor
+@using StandManager.Utils
@inject IManagerService _managerService
+
+@inject DialogService _dialogService
@inject NavigationManager _navManager
\ No newline at end of file
diff --git a/StandManager/Program.cs b/StandManager/Program.cs
index b01cdb0..1d10b65 100644
--- a/StandManager/Program.cs
+++ b/StandManager/Program.cs
@@ -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()
- .AddInteractiveServerRenderMode();
+ .AddInteractiveServerRenderMode()
+ .AddInteractiveWebAssemblyRenderMode();
app.Use(async (context, func) =>
{
diff --git a/StandManager/StandManager.csproj b/StandManager/StandManager.csproj
index be52cf3..6a87646 100644
--- a/StandManager/StandManager.csproj
+++ b/StandManager/StandManager.csproj
@@ -8,6 +8,7 @@
+
diff --git a/StandManager/Utils/LayoutState.cs b/StandManager/Utils/LayoutState.cs
index 988d0f8..b7df024 100644
--- a/StandManager/Utils/LayoutState.cs
+++ b/StandManager/Utils/LayoutState.cs
@@ -1,4 +1,6 @@
-namespace StandManager.Utils;
+using Microsoft.AspNetCore.Components.Authorization;
+
+namespace StandManager.Utils;
public class LayoutState
{
@@ -11,4 +13,15 @@ public class LayoutState
BodyClass = cssClass;
OnChanged?.Invoke();
}
+}
+
+public static class MembershipUtils
+{
+ public static async Task GetUserId(AuthenticationStateProvider auth)
+ {
+ var state = await auth.GetAuthenticationStateAsync();
+ var idClaim = state.User.FindFirst("UserId")?.Value;
+
+ return Guid.Parse(idClaim ?? Guid.Empty.ToString());
+ }
}
\ No newline at end of file