using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using CurrieTechnologies.Razor.SweetAlert2; namespace Services { public class SwalUtils : ISwalUtils { private readonly SweetAlertService _service; public SwalUtils(SweetAlertService service) { _service = service; } public async Task ShowToast(string message) { return await _service.FireAsync( new SweetAlertOptions { Toast = true, Text = message, Timer = 5000 }); } public async Task ShowSwal(string title, string message, SweetAlertIcon icon) { if (icon == SweetAlertIcon.Question) return await _service.FireAsync(new SweetAlertOptions { ShowConfirmButton = true, CancelButtonColor = "Red", ShowCloseButton = false, ShowCancelButton = true, Html = message, Icon = icon, Title = title, CancelButtonText=Texts.NoButton, ConfirmButtonText=Texts.YesButton }); return await _service.FireAsync(new SweetAlertOptions { ShowConfirmButton = false, ShowCloseButton = false, ShowCancelButton = true, Html = message, Icon = icon, Title = title, CancelButtonText=Texts.OkButton }); } } }