| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- using SharedKernel.Helpers;
- using SharedKernel.Extensions;
- using Domain.Entities.Developers.ValueObject;
- using MediatR;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.AspNetCore.Mvc.RazorPages;
- using System.ComponentModel;
- using System.ComponentModel.DataAnnotations;
- namespace Admin.Pages.Developers.Apps;
- public class IndexModel(IMediator mediator) : PageModel
- {
- [BindProperty(SupportsGet = true)]
- public QueryParams Query { get; set; } = new();
- public sealed class QueryParams
- {
- public ApplicationStatus? Status { get; set; }
- public string? Keyword { get; set; }
- [Range(1, int.MaxValue)]
- [DisplayName("페이지 번호")]
- public int PageNum { get; set; } = 1;
- [Range(1, 100)]
- [DisplayName("페이지 목록 수")]
- public ushort PerPage { get; set; } = 20;
- }
- public int Total { get; set; }
- public List<Application.Features.Admin.Developers.ListApps.AppRow> List { get; set; } = [];
- public Pagination? Pagination { get; set; }
- public async Task OnGetAsync(CancellationToken ct)
- {
- if (!ModelState.IsValid)
- {
- return;
- }
- var result = await mediator.Send(new Application.Features.Admin.Developers.ListApps.Query(
- Query.Status, Query.Keyword, Query.PageNum, Query.PerPage
- ), ct);
- Total = result.Total;
- List = [..result.List];
- Pagination = new Pagination(result.Total, Query.PageNum, Query.PerPage);
- }
- public async Task<IActionResult> OnPostApproveAsync(int[] ids, CancellationToken ct)
- {
- try
- {
- var result = await mediator.Send(new Application.Features.Admin.Developers.ApproveApp.Command(ids), ct);
- TempData["SuccessMessage"] = $"{result.AffectedCount}개 앱이 승인되었습니다.";
- }
- catch (Exception e)
- {
- TempData["ErrorMessages"] = e.Message;
- }
- return RedirectToPage("/Developers/Apps/Index", Query);
- }
- public async Task<IActionResult> OnPostSuspendAsync(int[] ids, CancellationToken ct)
- {
- try
- {
- var result = await mediator.Send(new Application.Features.Admin.Developers.SuspendApp.Command(ids), ct);
- TempData["SuccessMessage"] = $"{result.AffectedCount}개 앱이 정지되었습니다.";
- }
- catch (Exception e)
- {
- TempData["ErrorMessages"] = e.Message;
- }
- return RedirectToPage("/Developers/Apps/Index", Query);
- }
- }
|