using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using vendorApproverBackend.Enums; using vendorApproverBackend.Requests; using vendorApproverBackend.Services; namespace vendorApproverBackend.Controllers { [ApiController] [Route("api/pq-clarifications")] public class PqClarificationController : ControllerBase { private readonly PqClarificationService _service; public PqClarificationController(PqClarificationService service) { _service = service; } [HttpPost("add")] [Authorize(Roles = "ADMIN,EMPLOYEE,VENDOR,PERFERMANCE_MANAGER")] public async Task Create([FromBody] CreatePqClarificationDto request) { return Ok(await _service.AddPqClarificationAsync(request)); } [HttpGet("get-by-id/{id}")] [Authorize(Roles = "ADMIN,EMPLOYEE,VENDOR,PERFERMANCE_MANAGER")] public async Task GetById(long id) { var result = await _service.GetByIdAsync(id); return result != null ? Ok(result) : NotFound(); } [HttpGet("all-pq-clarifications-by-request/{requestId}")] [Authorize(Roles = "ADMIN,EMPLOYEE,VENDOR,PERFERMANCE_MANAGER")] public async Task GetByRequest(long requestId, [FromQuery] PqClarificationRoleEnum? receiver = null) { return Ok(await _service.GetByRequestIdAsync(requestId, receiver)); } } }