Exemple #1
0
 protected void Application_Start()
 {
     GlobalConfiguration.Configure(WebApiConfig.Register);
     NhibernateSetup.Init();
     Mapper.Initialize(cfg => cfg.AddProfiles(typeof(QuestaoMapper).Assembly));
     log4net.Config.XmlConfigurator.Configure();
 }
        private Interface.Resolucao Ctor(List <ResolucaoQuestao> arg)
        {
            var resolucao = new Interface.Resolucao();

            resolucao.Questoes = Mapper.Map <List <Interface.Questao> >(arg);

            var resolucoes      = new Resolucoes(NhibernateSetup.GetSession());
            var resolucaoTarefa = resolucoes.ResolucaoTarefaPorTarefaEAluno(arg[0].Aluno.Id, arg[0].Tarefa.Id);

            resolucao.Enviada = resolucaoTarefa.Enviada;
            resolucao.Nota    = resolucaoTarefa.Nota;

            return(resolucao);
        }
        private List <ResolucaoQuestao> ObterResolucaoQuestao(Interface.Resolucao arg)
        {
            var resolucoes      = new Resolucoes(NhibernateSetup.GetSession());
            var listaResolucoes = resolucoes.ResolucaoQuestaoPorTarefaEAluno(arg.IdTarefa, arg.Questoes.First().IdAluno).ToList();

            if (listaResolucoes.Any())
            {
                foreach (var resolucaoQuestao in listaResolucoes)
                {
                    resolucaoQuestao.Comentario = arg.Questoes.First(q => q.Id == resolucaoQuestao.Questao.Id).Comentario;
                    resolucaoQuestao.Resposta   = arg.Questoes.First(q => q.Id == resolucaoQuestao.Questao.Id).Resposta;
                }
            }

            var tarefas  = new Tarefas(NhibernateSetup.GetSession());
            var alunos   = new Alunos(NhibernateSetup.GetSession());
            var questoes = new Questoes(NhibernateSetup.GetSession());

            var tarefa = tarefas.Por(arg.IdTarefa);
            var aluno  = alunos.Por(arg.Questoes.First().IdAluno);

            var novasQuestoes = new List <Interface.Questao>();

            foreach (var questao in arg.Questoes.Where(q => q.Resposta != null))
            {
                if (listaResolucoes.All(l => l.Questao.Id != questao.Id))
                {
                    novasQuestoes.Add(questao);
                }
            }

            foreach (var questao in novasQuestoes)
            {
                var resolucaoQuestao = new ResolucaoQuestao();
                resolucaoQuestao.Tarefa     = tarefa;
                resolucaoQuestao.Aluno      = aluno;
                resolucaoQuestao.Resposta   = questao.Resposta;
                resolucaoQuestao.Comentario = questao.Comentario;

                resolucaoQuestao.Questao = questoes.Por(questao.Id);

                listaResolucoes.Add(resolucaoQuestao);
            }

            return(listaResolucoes);
        }
Exemple #4
0
        protected void Application_Start()
        {
            GlobalConfiguration.Configure(WebApiConfig.Register);

            NhibernateSetup.Init();

            //Migração inicial
            var caminhoBanco = new AppSettingsReader().GetValue("Banco.Arquivo", typeof(string)).ToString();

            Migrador.Configuracao.RealizarUpgrade(caminhoBanco);

            //Configurando injeção de dependência
            var container = Configuracoes.SimpleInjector.ObterContainer();

            container.RegisterWebApiControllers(GlobalConfiguration.Configuration);
            container.Verify();

            GlobalConfiguration.Configuration.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container);
        }
        private Tarefa ObterTarefa(Interface.Tarefa tarefaInterface)
        {
            var questoes    = new Questoes(NhibernateSetup.GetSession());
            var professores = new Professores(NhibernateSetup.GetSession());

            var listaQuestoes = new List <Questao>();

            foreach (var questao in tarefaInterface.Questoes)
            {
                listaQuestoes.Add(questoes.Por(questao.Id));
            }

            var professor = professores.Por(tarefaInterface.IdProfessor);

            var tarefa = new Tarefa {
                Questoes  = listaQuestoes,
                Professor = professor
            };

            return(tarefa);
        }
Exemple #6
0
 public void TestFixtureSetup()
 {
     NhSetup = new NhibernateSetup();
 }
 public TurmaController() : this(new Turmas(NhibernateSetup.GetSession()),
                                 new Tarefas(NhibernateSetup.GetSession()),
                                 new Resolucoes(NhibernateSetup.GetSession()))
 {
 }
Exemple #8
0
 public ResolucaoQuestaoController() : this(new Resolucoes(NhibernateSetup.GetSession()))
 {
 }
Exemple #9
0
        private Professor ObterProfessor(int id)
        {
            var professores = new Professores(NhibernateSetup.GetSession());

            return(professores.Por(id));
        }
 public void InitSetup()
 {
     config = new NhibernateSetup();
 }
 QuestoesController() : this(new Questoes(NhibernateSetup.GetSession()),
                             new Tarefas(NhibernateSetup.GetSession()),
                             Mapper.Instance
                             )
 {
 }
 public UsuarioController() : this(new Usuarios(NhibernateSetup.GetSession()))
 {
 }
Exemple #13
0
 public void InitSetup()
 {
     config = new NhibernateSetup();
 }
 public TarefasController() : this(new Tarefas(NhibernateSetup.GetSession()),
                                   new Resolucoes(NhibernateSetup.GetSession()),
                                   Mapper.Instance)
 {
 }