예제 #1
0
        public async Task <IActionResult> Atualizar(AlunoViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (!_alunoService.Buscar(p => p.Id == model.Id).Result.Any())
            {
                return(NotFound());
            }

            try
            {
                var aluno = _mapper.Map <Aluno>(model);
                await _alunoService.Atualizar(aluno);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }


            return(Accepted(nameof(ObterPorId), new { id = model.Id }));
        }