You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

59 lines
1.7 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using CurrieTechnologies.Razor.SweetAlert2;
  6. namespace Services
  7. {
  8. public class SwalUtils : ISwalUtils
  9. {
  10. private readonly SweetAlertService _service;
  11. public SwalUtils(SweetAlertService service)
  12. {
  13. _service = service;
  14. }
  15. public async Task<SweetAlertResult> ShowToast(string message)
  16. {
  17. return await _service.FireAsync(
  18. new SweetAlertOptions
  19. {
  20. Toast = true,
  21. Text = message,
  22. Timer = 5000
  23. });
  24. }
  25. public async Task<SweetAlertResult> ShowSwal(string title, string message, SweetAlertIcon icon)
  26. {
  27. if (icon == SweetAlertIcon.Question)
  28. return await _service.FireAsync(new SweetAlertOptions
  29. {
  30. ShowConfirmButton = true,
  31. CancelButtonColor = "Red",
  32. ShowCloseButton = false,
  33. ShowCancelButton = true,
  34. Html = message,
  35. Icon = icon,
  36. Title = title,
  37. CancelButtonText=Texts.NoButton,
  38. ConfirmButtonText=Texts.YesButton
  39. });
  40. return await _service.FireAsync(new SweetAlertOptions
  41. {
  42. ShowConfirmButton = false,
  43. ShowCloseButton = false,
  44. ShowCancelButton = true,
  45. Html = message,
  46. Icon = icon,
  47. Title = title,
  48. CancelButtonText=Texts.OkButton
  49. });
  50. }
  51. }
  52. }