Skip to content

Instantly share code, notes, and snippets.

@umayeras
Last active November 12, 2021 10:56
Show Gist options
  • Save umayeras/4e7df01647e423c03cdbbd06f5b42ff7 to your computer and use it in GitHub Desktop.
Save umayeras/4e7df01647e423c03cdbbd06f5b42ff7 to your computer and use it in GitHub Desktop.
[HttpGet("{id}")]
[ProducesResponseType(typeof(ServiceResponse), (int) HttpStatusCode.BadRequest)]
[ProducesResponseType(typeof(ServiceResponse), (int) HttpStatusCode.NotFound)]
[ProducesResponseType(typeof(ServiceResponse), (int) HttpStatusCode.OK)]
public async Task<IActionResult> Get(int id)
{
if (id <= 0)
{
return BadRequest(Messages.InvalidRequest);
}
var query = new GetSampleByIdQuery(id);
var sample = await Mediator.Send(query);
if (sample.Data == null)
{
return NotFound(Messages.SampleNotFound);
}
return Ok(sample);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment