public async Task <bool> QuestionAsync(string mensagem) { var objResult = false; SweetAlertResult result = await Swal.FireAsync(new SweetAlertOptions { Title = mensagem, Text = "Verifique os dados corretamente!", Icon = SweetAlertIcon.Question, ShowCancelButton = true, ConfirmButtonText = "Confirmar", CancelButtonText = "Cancelar" }); if (!string.IsNullOrEmpty(result.Value)) { objResult = true; } else if (result.Dismiss == DismissReason.Cancel) { await Swal.FireAsync( "Cancelada", "Operação CANCELADA pelo USUÁRIO!", SweetAlertIcon.Error ); } return(objResult); }
public static Task ReceiveFireResult(string requestId, SweetAlertResult result) { var requestGuid = Guid.Parse(requestId); PendingFireRequests.TryGetValue(requestGuid, out TaskCompletionSource <SweetAlertResult> pendingTask); PendingFireRequests.Remove(requestGuid); pendingTask.SetResult(result); return(Task.CompletedTask); }
/// <summary> /// Closes the currently open SweetAlert2 modal programmatically. /// </summary> /// <param name="result">The promise originally returned by <code>Swal.FireAsync()</code> will be resolved with this value. /// <para>If no object is given, the promise is resolved with an empty ({}) <code>SweetAlertResult</code> object.</para> /// </param> public async Task CloseAsync(SweetAlertResult result) { await jSRuntime.InvokeAsync <object>($"{JS_NAMESPACE}.CloseResult", result).ConfigureAwait(false); }
/// <summary> /// Closes the currently open SweetAlert2 modal programmatically. /// </summary> /// <param name="result">The promise originally returned by <code>Swal.FireAsync()</code> will be resolved with this value. /// <para>If no object is given, the promise is resolved with an empty ({}) <code>SweetAlertResult</code> object.</para> /// </param> public Task CloseAsync(SweetAlertResult result) { return(this.swal.CloseAsync(result)); }