public async Task <IActionResult> ObterPresenca([FromRoute] string id) { var presenca = await _presencaService.ObterPresencaAsync(Guid.Parse(id)); if (presenca == null) { return(NotFound()); } var response = new ObterPresencaResponse { Id = presenca.Id, Observacao = presenca.Observacao }; return(Ok(response)); }
public async Task <IActionResult> CriarPresenca([FromBody] CriarPresencaPostRequest presencaContract) { var presenca = new Presenca { Observacao = presencaContract.Observacao, UserId = HttpContext.ObterIdUsuario().ToString(), }; var inserido = await _presencaService.CriarPresencaAsync(presenca); var baseUrl = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}"; var location = baseUrl + ApiRoutes.Presencas.Obter.Replace("{id}", presenca.Id.ToString()); var response = new ObterPresencaResponse { Id = presenca.Id, Observacao = presenca.Observacao, }; return(Created(location, response)); }