a6068e184b
Refactored SiteSettingsController to FastEndpoints pattern: - Created GetEndpoint.cs: GET /api/sitesettings (authorized) - Created SaveEndpoint.cs: PUT /api/sitesettings (authorized) - Removed legacy SiteSettingsController.cs Both endpoints use Bearer token authentication and are auto-discovered by FastEndpoints configuration in Program.cs. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
using FastEndpoints;
|
|
using TaxBaik.Application.Services;
|
|
|
|
namespace TaxBaik.Web.Endpoints.AdminDashboard;
|
|
|
|
public class GetRecentInquiriesEndpoint : Endpoint<RecentInquiriesQuery, RecentInquiriesResponse>
|
|
{
|
|
private readonly AdminDashboardService _dashboardService;
|
|
|
|
public GetRecentInquiriesEndpoint(AdminDashboardService dashboardService)
|
|
{
|
|
_dashboardService = dashboardService;
|
|
}
|
|
|
|
public override void Configure()
|
|
{
|
|
Get("/api/admin-dashboard/recent-inquiries");
|
|
Policies("Bearer");
|
|
}
|
|
|
|
public override async Task HandleAsync(RecentInquiriesQuery request, CancellationToken ct)
|
|
{
|
|
try
|
|
{
|
|
var limit = request.Limit <= 0 ? 10 : request.Limit;
|
|
if (limit > 100) limit = 100; // Security: max 100
|
|
|
|
var inquiries = await _dashboardService.GetRecentInquiriesAsync(limit, ct);
|
|
await SendAsync(new RecentInquiriesResponse
|
|
{
|
|
Data = inquiries.ToList(),
|
|
Limit = limit
|
|
}, 200, cancellation: ct);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
await SendErrorsAsync(500, ct);
|
|
}
|
|
}
|
|
}
|