public ActionResult GetById(int id) { var env = _mapper.Map <EnvironmentViewModel>(_repo.FindById(id)); if (env is null) { return(NoContent()); } return(Ok(env)); }
public ObjectResult GetById([FromRoute] int id) { try { Domain.Models.Environment environment = _repository.FindById(id); if (environment == null) { return(NotFound("Ambiente inexistente.")); } var environmentDTO = _mapper.Map <EnvironmentViewDTO>(environment); return(Ok(environmentDTO)); } catch (Exception ex) { return(StatusCode(500, $"Ocorreu um erro inesperado: {ex.Message}")); } }