public async Task <Ranking> SomarNotaRankingAluno(ObjetivoAluno _aluno, AlunoTurma _alunoTurma)
        {
            try
            {
                //Buscando os dados do Usuario de acordo com o IdUsuairo inserindo no objeto alunoTurma
                Usuario usuario = _repositoryUsuario.BuscarUsuarioPorId((int)_alunoTurma.IdUsuario);

                //Procurando o ranking do aluno para poder alterar sua nota
                Ranking _rankingProcurado = BuscarRankingDoAluno(usuario.Nome);

                //Adicionando a nota atribuida ao objetivo concluido a sua nota geral do ranking
                _rankingProcurado.NotaTotal += _aluno.Nota;

                //Buscando os dados do Objetivo concluido para verficarmos se o mesmo é um objetivo oculto
                Objetivo _objetivo = _repositoryObjetivo.BuscarObjetivoPorId((int)_aluno.IdObjetivo);

                //Caso seja um objetivo oculto, somaremos a quantidade de objetivos oculto concluidos do aluno
                if (_objetivo.IdCategoria == 3)
                {
                    _rankingProcurado.ObjetivosOculto += 1;
                }

                //Salvando as alterações da nota do aluno
                _contexto.Entry(_rankingProcurado).State = EntityState.Modified;

                await _contexto.SaveChangesAsync();

                return(_rankingProcurado);
            }catch (Exception _e)
            {
                throw new Exception(_e.Message);
            }
        }
Exemple #2
0
        public async Task <IActionResult> PutDica(Guid id, Dica dica)
        {
            if (id != dica.IdDica)
            {
                return(BadRequest());
            }

            _context.Entry(dica).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DicaExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #3
0
        public async Task <IActionResult> PutUsuario(int id, Usuario usuario)
        {
            if (id != usuario.IdUsuario)
            {
                return(BadRequest());
            }

            _context.Entry(usuario).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!UsuarioExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ObjetivoAluno> AlterarObjetivosDoAluno(ObjetivoAluno _objetivoAluno)
        {
            try
            {
                //Verificando o objetivoAluno previamente cadastrados para verificar as alterações
                ObjetivoAluno _objetivo = BuscarObjetivoDoAlunoPorId(_objetivoAluno.Id);

                //Buscando o objeto alunoTurma de acordo com o IdAlunoTurma do objetivoAluno cadastrado
                AlunoTurma _alunoTurma = _alunoTurmaRepository.BuscarAlunoTurmaPorId((int)_objetivoAluno.IdAlunoTurma);

                //Passando ambos os objetos para o nosso ranking, para reavaliarmos a nota do aluno
                await _rankingRepository.AlterarNotaRankingAluno(_objetivoAluno, _objetivo, _alunoTurma);

                _objetivo.IdAlunoTurma = _objetivoAluno.IdAlunoTurma;
                _objetivo.IdObjetivo   = _objetivoAluno.IdObjetivo;
                _objetivo.Nota         = _objetivoAluno.Nota;


                _contexto.Entry(_objetivo).State = EntityState.Modified;

                await _contexto.SaveChangesAsync();

                return(_objetivo);
            }
            catch (Exception _e)
            {
                throw new Exception(_e.Message);
            }
        }
        public async Task <IActionResult> PutInstituicao(Guid id, Instituicao instituicao)
        {
            if (id != instituicao.IdInstituicao)
            {
                return(BadRequest());
            }

            _context.Entry(instituicao).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!InstituicaoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> PutObjetivoAluno(Guid id, ObjetivoAluno objetivoAluno)
        {
            if (id != objetivoAluno.IdOjetivoAluno)
            {
                return(BadRequest());
            }

            _context.Entry(objetivoAluno).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ObjetivoAlunoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <Perfils> AlterarPerfil(Perfils _perfil)
        {
            try
            {
                _contexto.Entry(_perfil).State = EntityState.Modified;
                await _contexto.SaveChangesAsync();

                return(_perfil);
            }catch (Exception _e) {
                throw new Exception(_e.Message);
            }
        }
        public async Task <Usuarios> AlterarUsuario(Usuarios _usuario)
        {
            try
            {
                _contexto.Entry(_usuario).State = EntityState.Modified;
                await _contexto.SaveChangesAsync();

                return(_usuario);
            }catch (Exception _e) {
                throw new Exception(_e.Message);
            }
        }
        public Usuario AlterarUsuario(Usuario _usuario)
        {
            try
            {
                _contexto.Entry(_usuario).State = EntityState.Modified;

                _contexto.SaveChanges();

                return(_usuario);
            }catch (Exception _e) {
                throw new Exception(_e.Message);
            }
        }
Exemple #10
0
        /// <summary>
        /// Alterar os dados de um perfil específico
        /// </summary>
        /// <param name="_perfil">Código de identificação do perfil</param>
        /// <returns>Perfil com os novos dados inseridos</returns>
        public Perfil AlterarPerfil(Perfil _perfil)
        {
            try
            {
                _contexto.Entry(_perfil).State = EntityState.Modified;
                _contexto.SaveChanges();

                return(_perfil);
            }
            catch (Exception _e)
            {
                throw new Exception(_e.Message);
            }
        }
        public AlunoTurma AlterarTurmaDoAluno(AlunoTurma _alunoTurma)
        {
            try
            {
                _contexto.Entry(_alunoTurma).State = EntityState.Modified;

                _contexto.SaveChanges();

                return(_alunoTurma);
            }
            catch (Exception _e)
            {
                throw new Exception(_e.Message);
            }
        }
Exemple #12
0
        public Dica AlterarDica(Dica _dica)
        {
            try
            {
                _contexto.Entry(_dica).State = EntityState.Modified;

                _contexto.SaveChanges();

                return(_dica);
            }
            catch (Exception _e)
            {
                throw new Exception(_e.Message);
            }
        }
Exemple #13
0
        public ProfessorTurma AlterarTurmaDoProfessor(ProfessorTurma _professorTurma)
        {
            try
            {
                _contexto.Entry(_professorTurma).State = EntityState.Modified;

                _contexto.SaveChanges();

                return(_professorTurma);
            }
            catch (Exception _e)
            {
                throw new Exception(_e.Message);
            }
        }
        public Curso AlterarCurso(Curso _curso)
        {
            try
            {
                _contexto.Entry(_curso).State = EntityState.Modified;

                _contexto.SaveChanges();

                return(_curso);
            }
            catch (Exception _e)
            {
                throw new Exception(_e.Message);
            }
        }
Exemple #15
0
        public ObjetivoAluno AlterarObjetivosDoAluno(ObjetivoAluno _objetivoAluno)
        {
            try
            {
                ObjetivoAluno _objetivo = BuscarObjetivoDoAlunoPorId(_objetivoAluno.Id);

                _contexto.Entry(_objetivoAluno).State = EntityState.Modified;

                _contexto.SaveChanges();

                return(_objetivoAluno);
            }
            catch (Exception _e)
            {
                throw new Exception(_e.Message);
            }
        }