Beispiel #1
0
        [ApplyModelValidation]                                      //Decorator filtro
        public IHttpActionResult Post([FromBody] AlunoDTO alunoDTO) //Mais recomendado com IHttpActionResult
        {
            try
            {
                Aluno aluno = AutoMapperManager.Instance.Mapper.Map <AlunoDTO, Aluno>(alunoDTO); //Mapear do AlunoDTO para Aluno

                _repositorioAlunos.Inserir(aluno);
                return(Created($"{Request.RequestUri}/{aluno.Id}", aluno));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }