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 async Task <bool> ShowSucsessAsync(IJSRuntime jsRuntime, string message) { SweetAlertOptions alertOptions = CreateSuccessSweetAlert(message); SweetAlertResult result = await SweetPopUptAsync(jsRuntime, alertOptions); return(result.IsConfirmed); }
private async Task <SweetAlertResult> SweetPopUptAsync(IJSRuntime jsRuntime, SweetAlertOptions sweetAlert) { try { Swal = new SweetAlertService(jsRuntime); SweetAlertResult result = await Swal.FireAsync(sweetAlert); return(result); } catch (Exception ex) { return(new SweetAlertResult() { Value = $"SweetError: {ex.Message}" }); } }
protected async Task <bool> MessageBoxModal(string titulo, string conteudo, string icone, string textoConfirma = "Confirma", string textoCancela = "Cancela", bool isConfirmed = true, bool isHtml = false) { // _ = BlazoredModal.Close().ConfigureAwait(false); bool choice = false; var myicone = (SweetAlertIcon)icone; if (!isConfirmed) { textoConfirma = "Ok"; } await Swal.FireAsync(new SweetAlertOptions { Title = titulo, Html = isHtml ? conteudo : null, Text = conteudo, AllowEnterKey = true, Icon = myicone, ShowCancelButton = isConfirmed, ConfirmButtonText = textoConfirma, CancelButtonText = textoCancela, CancelButtonColor = "error", AllowEscapeKey = true }).ContinueWith(swalTask => { SweetAlertResult result = swalTask.Result; if (result.Dismiss != DismissReason.Cancel) { choice = true; } else if (result.Dismiss == DismissReason.Cancel) { Swal.FireAsync( "Oops!!!!!", "Ação Cancelada!", SweetAlertIcon.Error ); } }); return(choice); }
public async Task AlertAsyncDelete(EmpresaModel Empresa) { SweetAlertResult result = await Swal.FireAsync(new SweetAlertOptions { Title = "¿Desea eliminar a " + Empresa.RazonSocial + "?", Text = "Esta acción es irreversible", Icon = SweetAlertIcon.Warning, ShowCancelButton = true, ConfirmButtonText = "Eliminar", CancelButtonText = "Cancelar" }); if (!string.IsNullOrEmpty(result.Value)) { await DeleteEmpresaAsync(Empresa); await Swal.FireAsync( "Eliminado", "La acción se realizó con exitó", SweetAlertIcon.Success ); } }