public void GerarTeste(Teste teste, Materia materia, Questao questao) { try { IList <Questao> questaoList = questaoDAO.GetAllRandom(teste, materia, questao); if (teste.QuantidadeQuestoes > questaoList.Count) { throw new Exception("A quantidade de questões do " + questao.Bimestre + " e na Matéria " + materia.Nome + " é de " + questaoList.Count); } else { if (questaoList.Count < 1) { throw new Exception("Não há nenhuma questão cadastrada nesse Bimestre e nessa matéria"); } else { int testeID = testeDAO.AdicionarTBTestes(teste); teste.ID = testeID; foreach (var item in questaoList) { testeDAO.AdicionarTBTestes_Questoes(Convert.ToInt32(item.ID), testeID); } } } } catch (Exception ex) { throw new Exception(ex.Message); } }
public IList <Questao> GetAllRandom(Teste teste, Materia materia, Questao questao) { try { var List = _questaoDAO.GetAllRandom(teste, materia, questao); return(List); } catch (Exception e) { throw new Exception(e.Message); } }