Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

60 linhas
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 BlazorPages.Tools
  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. ConfirmButtonText = "خُب"
  24. });
  25. }
  26. public async Task<SweetAlertResult> ShowSwal(string title, string message, SweetAlertIcon icon)
  27. {
  28. if (icon == SweetAlertIcon.Question)
  29. return await _service.FireAsync(new SweetAlertOptions
  30. {
  31. ShowConfirmButton = true,
  32. CancelButtonColor = "Red",
  33. ShowCloseButton = false,
  34. ShowCancelButton = true,
  35. Html = message,
  36. Icon = icon,
  37. Title = title,
  38. CancelButtonText = "انصراف",
  39. ConfirmButtonText = "تائید"
  40. });
  41. return await _service.FireAsync(new SweetAlertOptions
  42. {
  43. ShowConfirmButton = false,
  44. ShowCloseButton = false,
  45. ShowCancelButton = true,
  46. Html = message,
  47. Icon = icon,
  48. Title = title,
  49. CancelButtonText = "خًب"
  50. });
  51. }
  52. }
  53. }