public IActionResult Get() { try { // Recebe a lista de "ProfessorTurma" var professorTurmas = _professorturmaRepository.Listar(); // Se a variável estiver nula retorna NoContent if (professorTurmas == null) { return(NoContent()); } else { return(Ok(new { totalCount = professorTurmas.Count(), data = professorTurmas })); } } catch (Exception) { return(BadRequest(new { statusCode = 400, error = "Erro 400, entrar em contato com o nosso suporte técnico" })); } }
public IActionResult Get() { try { //Listar os professores var professorTurma = _ProfessorTurmaRepository.Listar(); //Verifica se o professor existe (ou não) if (professorTurma.Count == 0) { return(NoContent()); } //Caso exista retorna OK e os objetivos return(Ok(new { totalCount = professorTurma.Count, data = professorTurma })); } catch { //Caso ocorra algum erro retorna BadRequest e a mensagem de erro //TODO: Não encontrado return(BadRequest(new { StatusCode = 400, error = "Não foi encontrado, informe o erro para [email protected]" })); } }
public IActionResult Get() { try { //lista de professores var prof = professorTRepository.Listar(); //verifica se existe no conxtexto atual //caso nao exista ele retorna NoContext if (prof.Count == 0) { return(NoContent()); } //caso exista retorno Ok e o total de professores cadastradss return(Ok(new { totalCount = prof.Count, data = prof })); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public IActionResult Get() { try { var professoresturmas = _professorTurmaRepository.Listar(); if (professoresturmas.Count == 0) { return(NoContent()); } return(Ok(professoresturmas)); } catch (Exception ex) { return(BadRequest(ex.Message)); } }