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);
        }
示例#2
0
        public async Task <bool> ShowSucsessAsync(IJSRuntime jsRuntime, string message)
        {
            SweetAlertOptions alertOptions = CreateSuccessSweetAlert(message);
            SweetAlertResult  result       = await SweetPopUptAsync(jsRuntime, alertOptions);

            return(result.IsConfirmed);
        }
示例#3
0
        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}"
                });
            }
        }
示例#4
0
        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
                    );
            }
        }