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));
        }
예제 #2
0
        protected async Task <ObterPresencaResponse> CriarPresencaAsync(CriarPresencaPostRequest request)
        {
            var response = await _testClient.PostAsJsonAsync(ApiRoutes.Presencas.Criar, request);

            return(await response.Content.ReadAsAsync <ObterPresencaResponse>());
        }