Пример #1
0
        public async Task <ActionResult <AlunoViewModel> > ObterPorId(int id)
        {
            AlunoViewModel model;

            try
            {
                var aluno = await _alunoService.BuscarPorID(id);

                if (aluno == null)
                {
                    return(NotFound());
                }

                model = _mapper.Map <AlunoViewModel>(aluno);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Ok(model));
        }