added extension methods
This commit is contained in:
parent
d2b4b1a0a0
commit
256bb47dfe
15
UserService/Extensions/JSInteropExtensions.cs
Normal file
15
UserService/Extensions/JSInteropExtensions.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.JSInterop;
|
||||||
|
|
||||||
|
public static class JSInteropExtensions
|
||||||
|
{
|
||||||
|
public static ValueTask<bool> Confirm(this IJSRuntime jsRuntime, string message)
|
||||||
|
{
|
||||||
|
return jsRuntime.InvokeAsync<bool>("confirm", message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ValueTask Alert(this IJSRuntime jsRuntime, string message)
|
||||||
|
{
|
||||||
|
return jsRuntime.InvokeVoidAsync("alert", message);
|
||||||
|
}
|
||||||
|
}
|
@ -45,8 +45,7 @@ namespace UserService.Pages
|
|||||||
protected override async Task RowDeletingCallback(CancellableRowChange<SecurityGroup> arg)
|
protected override async Task RowDeletingCallback(CancellableRowChange<SecurityGroup> arg)
|
||||||
{
|
{
|
||||||
if (arg == null) throw new ArgumentNullException(nameof(arg));
|
if (arg == null) throw new ArgumentNullException(nameof(arg));
|
||||||
var confirmed = await JsRuntime.InvokeAsync<bool>("confirm",
|
var confirmed = await JsRuntime.Confirm($"You are about to delete the security group {arg.Item.CommonName}. Are you sure?")
|
||||||
$"You are about to delete the security group {arg.Item.CommonName}. Are you sure?")
|
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
arg.Cancel = !confirmed;
|
arg.Cancel = !confirmed;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ namespace UserService.Pages
|
|||||||
Members ?? Enumerable.Empty<User>());
|
Members ?? Enumerable.Empty<User>());
|
||||||
if (mailValidation == true && commonNameValidation == true) return;
|
if (mailValidation == true && commonNameValidation == true) return;
|
||||||
|
|
||||||
await JsRuntime.InvokeVoidAsync("alert", "User could not be added").ConfigureAwait(false);
|
await JsRuntime.Alert("User could not be added").ConfigureAwait(false);
|
||||||
arg.Cancel = true;
|
arg.Cancel = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,8 +46,7 @@ namespace UserService.Pages
|
|||||||
protected override async Task RowDeletingCallback(CancellableRowChange<User> arg)
|
protected override async Task RowDeletingCallback(CancellableRowChange<User> arg)
|
||||||
{
|
{
|
||||||
if (arg == null) throw new ArgumentNullException(nameof(arg));
|
if (arg == null) throw new ArgumentNullException(nameof(arg));
|
||||||
var confirmed = await JsRuntime.InvokeAsync<bool>("confirm",
|
var confirmed = await JsRuntime.Confirm($"You are about to delete the user {arg.Item.FullName}. Are you sure?").ConfigureAwait(false);
|
||||||
$"You are about to delete the user {arg.Item.FullName}. Are you sure?").ConfigureAwait(false);
|
|
||||||
arg.Cancel = !confirmed;
|
arg.Cancel = !confirmed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user