You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
83 lines
2.7 KiB
83 lines
2.7 KiB
using System.Net;
|
|
using DTO;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Shared;
|
|
|
|
namespace WfApi.Controllers
|
|
{
|
|
[Route("api/v1/source")]
|
|
[ApiController]
|
|
public class SourceController : ControllerBase
|
|
{
|
|
private readonly ISourceService<SourceDTO> _source;
|
|
|
|
private readonly ILogger<SourceController> _logger;
|
|
public SourceController(ISourceService<SourceDTO> sourceService, ILogger<SourceController> logger)
|
|
{
|
|
_source = sourceService;
|
|
_logger = logger;
|
|
|
|
}
|
|
|
|
[HttpGet("{id}")] // Indiquer que l'id est dans l'URL
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<IActionResult> GetSource(int id)
|
|
{
|
|
try
|
|
{
|
|
var source = await _source.GetSourceById(id);
|
|
if(source != null)
|
|
{
|
|
return Ok(source);
|
|
}
|
|
else
|
|
{
|
|
return NoContent();
|
|
}
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
return StatusCode((int)HttpStatusCode.InternalServerError, new { message = "Internal Server Error (" + e + ")" });
|
|
}
|
|
}
|
|
|
|
/*[HttpGet("all")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<IActionResult> GetAllSource(int index = 0, int count = 10)
|
|
{
|
|
|
|
}
|
|
|
|
[HttpPost]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<IActionResult> CreateSource([FromBody] SourceDTO newSource)
|
|
{
|
|
|
|
}
|
|
|
|
[HttpPut()]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<IActionResult> UpdateSource([FromQuery] int id, [FromBody] SourceDTO updatedSource)
|
|
{
|
|
|
|
}
|
|
|
|
[HttpDelete("delete")]
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
|
public async Task<IActionResult> DeleteSource([FromQuery] int idSource)
|
|
{
|
|
|
|
}*/
|
|
}
|
|
}
|