Index.cshtml.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using SharedKernel.Helpers;
  2. using Domain.Entities.Developers.ValueObject;
  3. using Application.Abstractions.Messaging;
  4. using Microsoft.AspNetCore.Mvc;
  5. using Microsoft.AspNetCore.Mvc.RazorPages;
  6. using System.ComponentModel;
  7. using System.ComponentModel.DataAnnotations;
  8. namespace Admin.Pages.Developers.Accounts;
  9. public class IndexModel(IMediator mediator) : PageModel
  10. {
  11. [BindProperty(SupportsGet = true)]
  12. public QueryParams Query { get; set; } = new();
  13. public sealed class QueryParams
  14. {
  15. public DeveloperApprovalStatus? ApprovalStatus { get; set; }
  16. public KycStatus? KycStatus { get; set; }
  17. public string? Keyword { get; set; }
  18. [Range(1, int.MaxValue)]
  19. [DisplayName("페이지 번호")]
  20. public int PageNum { get; set; } = 1;
  21. [Range(1, 100)]
  22. [DisplayName("페이지 목록 수")]
  23. public ushort PerPage { get; set; } = 20;
  24. }
  25. public int Total { get; set; }
  26. public List<Application.Features.Admin.Developers.Accounts.ListDevelopers.DeveloperRow> List { get; set; } = [];
  27. public Pagination? Pagination { get; set; }
  28. public async Task OnGetAsync(CancellationToken ct)
  29. {
  30. if (!ModelState.IsValid)
  31. {
  32. return;
  33. }
  34. var result = await mediator.Send(new Application.Features.Admin.Developers.Accounts.ListDevelopers.Query(
  35. Query.ApprovalStatus, Query.KycStatus, Query.Keyword, Query.PageNum, Query.PerPage
  36. ), ct);
  37. Total = result.Total;
  38. List = [..result.List];
  39. Pagination = new Pagination(result.Total, Query.PageNum, Query.PerPage);
  40. }
  41. }