using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using TaxBaik.Application.Services;
using TaxBaik.Domain.Entities;
using TaxBaik.Web.Services;

namespace TaxBaik.Web.Pages.Admin.Inquiries;

[Authorize(AuthenticationSchemes = AdminAuthDefaults.Scheme)]
public class DetailModel(InquiryService inquiryService) : PageModel
{
    public Inquiry? Inquiry { get; private set; }

    public async Task<IActionResult> OnGetAsync(int id, CancellationToken ct)
    {
        Inquiry = await inquiryService.GetByIdAsync(id, ct);
        return Page();
    }

    public async Task<IActionResult> OnPostDeleteAsync(int id, CancellationToken ct)
    {
        await inquiryService.DeleteAsync(id, ct);
        return RedirectToPage("/Admin/Inquiries/Index");
    }
}
