Пример #1
0
        public async Task <IActionResult> Put(long id, [FromBody] AnamneseInputDTO inputDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var anamnese = new Anamnese(inputDTO.HabitosGerais, inputDTO.Sedentarismo, inputDTO.Cirurgias, inputDTO.AlunoId);
                anamnese.Id = id;
                var result = await _service.Put(anamnese);

                if (result != null)
                {
                    return(Ok(result));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (ArgumentException e)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message));
            }
        }
Пример #2
0
        public async Task <IActionResult> Post([FromBody] AnamneseInputDTO inputDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            try
            {
                var anamnese = new Anamnese(inputDTO.HabitosGerais, inputDTO.Sedentarismo, inputDTO.Cirurgias, inputDTO.AlunoId);
                var result   = await _service.Post(anamnese);

                if (result != null)
                {
                    return(Created(new Uri(Url.Link("GetWithId", new { id = result.Id })), result));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (ArgumentException e)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, e.Message));
            }
        }