using Microsoft.AspNetCore.Mvc; using ProximaContracts.Application.Contracts.Services; using ProximaContracts.Domain.Contracts.DTOs.Request; namespace ProximaContracts.API.Controllers { [Route("api/[controller]")] [ApiController] public class ContractsController(IContractService service) : ControllerBase { private readonly IContractService _service = service; [HttpGet("GetAll")] public async Task GetContracts() { var response = await _service.GetContracts(); return response.Any() ? Ok(response) : NotFound(); } [HttpGet("GetById")] public async Task GetContractsById([FromQuery] ContractByIdRequestDto dto) { var response = await _service.GetContractById(dto); return response != null ? Ok(response) : NotFound(); } [HttpPost("CreateContract")] public async Task CreateContract([FromBody] CreateContractRequestDto dto) { var result = await _service.CreateContract(dto); if(result.IsCreated) { return Ok(result); } else { return BadRequest(result); } } [HttpPut("UpdateContract")] public async Task UpdateContract([FromBody] UpdateContractRequestDto dto) { var result = await _service.UpdateContract(dto); if (result.IsUpdated) { return Ok(result); } else { return BadRequest(result); } } } }