public IActionResult Delete(int id, [FromServices] IDepartamentoRepository repository) { try { var departamento = repository.ObterPorId(id); repository.Excluir(departamento); return(Ok("Departamento excluĂdo com sucesso.")); } catch (Exception e) { return(StatusCode(500, e.Message)); } }
public IActionResult GetById(int id, [FromServices] IDepartamentoRepository repository, [FromServices] IMapper mapper) { try { var model = mapper.Map <DepartamentoConsultaModel> (repository.ObterPorId(id)); return(Ok(model)); } catch (Exception e) { return(StatusCode(500, e.Message)); } }