Created
December 3, 2018 06:56
-
-
Save pedrovasconcellos/f966879e9f6fb22fa4b1a75af37cca46 to your computer and use it in GitHub Desktop.
Example of a documented endpoint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Realiza a consulta por id do carro | |
/// </summary> | |
/// <param name="id"></param> | |
/// <response code="200">Ok</response> | |
/// <response code="400">Bad Request</response> | |
/// <response code="404">Not Found</response> | |
/// <response code="500">Internal Server Error</response> | |
[HttpGet("{id}")] | |
[ProducesResponseType(typeof(IList<CarModel>),200)] | |
[ProducesResponseType(typeof(IList<Error>),400)] | |
[ProducesResponseType(404)] | |
[ProducesResponseType(500)] | |
public async Task<ActionResult<IList<CarModel>>> GetById(int id) | |
{ | |
var entity = this._context.Car.Include(x => x.Color).FirstOrDefault(x => x.Id == id); | |
if(entity == null) return await Task.FromResult(this.NotFound()); | |
return await Task.FromResult(this.Ok(_mapper.Map<List<CarModel>>(entity))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment