Cache.cshtml.cs 756 B

1234567891011121314151617181920212223242526272829
  1. using Application.Features.Admin.Cache.ClearCache;
  2. using MediatR;
  3. using Microsoft.AspNetCore.Mvc;
  4. using Microsoft.AspNetCore.Mvc.RazorPages;
  5. namespace Admin.Pages.Server;
  6. public class CacheModel(IMediator mediator) : PageModel
  7. {
  8. public void OnGet()
  9. {
  10. }
  11. public async Task<IActionResult> OnPostAsync(string? prefix, CancellationToken ct)
  12. {
  13. try
  14. {
  15. await mediator.Send(new Command(prefix), ct);
  16. TempData["SuccessMessage"] = string.IsNullOrEmpty(prefix) ? "전체 캐시가 삭제되었습니다." : $"'{prefix}' 캐시가 삭제되었습니다.";
  17. }
  18. catch (Exception e)
  19. {
  20. TempData["ErrorMessages"] = e.Message;
  21. }
  22. return RedirectToPage();
  23. }
  24. }