using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using ROLAC.API.Authorization;
using ROLAC.API.DTOs.Disbursement;
using ROLAC.API.Services;

namespace ROLAC.API.Controllers;

[ApiController]
[Route("api/church-profile")]
[Authorize]
public class ChurchProfileController : ControllerBase
{
    private readonly IChurchProfileService _svc;
    public ChurchProfileController(IChurchProfileService svc) => _svc = svc;

    [HttpGet]
    [HasPermission(Modules.ChurchProfile, PermissionActions.Read)]
    public async Task<IActionResult> Get() => Ok(await _svc.GetAsync());

    [HttpPut]
    [HasPermission(Modules.ChurchProfile, PermissionActions.Write)]
    public async Task<IActionResult> Update([FromBody] UpdateChurchProfileRequest r)
    {
        await _svc.UpdateAsync(r);
        return NoContent();
    }
}
