prueba tecnica

This commit is contained in:
Alejandro
2025-06-15 18:29:25 +02:00
parent 9758ee0bc6
commit d97e55a83f
127 changed files with 6488 additions and 1 deletions

View File

@@ -0,0 +1,58 @@
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<IActionResult> GetContracts()
{
var response = await _service.GetContracts();
return response.Any() ? Ok(response) : NotFound();
}
[HttpGet("GetById")]
public async Task<IActionResult> GetContractsById([FromQuery] ContractByIdRequestDto dto)
{
var response = await _service.GetContractById(dto);
return response != null ? Ok(response) : NotFound();
}
[HttpPost("CreateContract")]
public async Task<IActionResult> 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<IActionResult> UpdateContract([FromBody] UpdateContractRequestDto dto)
{
var result = await _service.UpdateContract(dto);
if (result.IsUpdated)
{
return Ok(result);
}
else
{
return BadRequest(result);
}
}
}
}