Esempio n. 1
0
        public void AtualizarAreAtuacaoDocente(Docente docente, List <AreaAtuacao> areaAtuacao)
        {
            this.Update(docente);
            this.Save();
            var ctx = new SPEContext();

            ctx.Configuration.LazyLoadingEnabled   = false;
            ctx.Configuration.ProxyCreationEnabled = false;
            List <AreaAtuacao> lista = new List <AreaAtuacao>();

            foreach (var item in areaAtuacao)
            {
                lista.Add(ctx.AreaAtuacao.Where(a => a.IdAreaAtuacao == item.IdAreaAtuacao).FirstOrDefault());
            }
            var DocenteAreaAtuacao = (from u in ctx.Docente.Include("AreaAtuacao")
                                      where u.IdDocente == docente.IdDocente
                                      select u).SingleOrDefault();

            if (DocenteAreaAtuacao != null && DocenteAreaAtuacao.AreaAtuacao.Count > 0)
            {
                foreach (var item in DocenteAreaAtuacao.AreaAtuacao.ToList())
                {
                    DocenteAreaAtuacao.AreaAtuacao.Remove(item);
                }
            }
            DocenteAreaAtuacao.AreaAtuacao = lista;
            ctx.SaveChanges();
            ctx.Dispose();
            Save();
        }
Esempio n. 2
0
        public void AtualizarAgendaDocente(Docente docente, List <Componente> componentes)
        {
            this.Update(docente);
            this.Save();
            var ctx = new SPEContext();

            ctx.Configuration.LazyLoadingEnabled   = false;
            ctx.Configuration.ProxyCreationEnabled = false;
            List <Componente> lista = new List <Componente>();

            foreach (var item in componentes)
            {
                lista.Add(ctx.Componente.Where(a => a.IdComponente == item.IdComponente).FirstOrDefault());
            }
            var DocenteComponente = (from u in ctx.Docente.Include("Componente")
                                     where u.IdDocente == docente.IdDocente
                                     select u).SingleOrDefault();

            if (DocenteComponente != null && DocenteComponente.Componente.Count > 0)
            {
                foreach (var item in DocenteComponente.Componente.ToList())
                {
                    DocenteComponente.Componente.Remove(item);
                }
            }
            DocenteComponente.Componente = lista;
            ctx.SaveChanges();
            ctx.Dispose();
            Save();
        }
Esempio n. 3
0
        public void AddList(List <Modulo> lista)
        {
            foreach (var item in lista)
            {
                var ctx = new SPEContext();
                ctx.Configuration.LazyLoadingEnabled   = false;
                ctx.Configuration.ProxyCreationEnabled = false;

                Modulo modulo = new Modulo();
                modulo.Nome     = item.Nome;
                modulo.IdMatriz = item.IdMatriz;
                var matriz = ctx.Matriz.Include("Modulo").Where(a => a.IdMatriz == item.IdMatriz).FirstOrDefault();


                foreach (var componente in item.Componente)
                {
                    Componente newComponente = (from u in ctx.Componente where u.IdComponente == componente.IdComponente select u).FirstOrDefault();
                    modulo.Componente.Add(newComponente);
                }
                ctx.Modulo.Add(modulo);
                ctx.SaveChanges();
                ctx.Dispose();

                this.Save();
            }
        }
Esempio n. 4
0
        public Componente VincularTipoCompentes(Componente componente, int[] idTipoAmbiente)
        {
            var ctx = new SPEContext();

            ctx.Configuration.LazyLoadingEnabled   = false;
            ctx.Configuration.ProxyCreationEnabled = false;
            var componenteTipoAmbiente = (from u in ctx.Componente.Include("TipoAmbiente")
                                          where u.IdComponente == componente.IdComponente
                                          select u).SingleOrDefault();

            if (componenteTipoAmbiente != null && componenteTipoAmbiente.TipoAmbiente.Count > 0)
            {
                foreach (var item in componenteTipoAmbiente.TipoAmbiente.ToList())
                {
                    componenteTipoAmbiente.TipoAmbiente.Remove(item);
                }
            }

            var tiposAmbiente = (from u in ctx.TipoAmbiente
                                 where idTipoAmbiente.Contains(u.IdTipoAmbiente)
                                 select u).ToList();

            foreach (var item in tiposAmbiente)
            {
                componenteTipoAmbiente.TipoAmbiente.Add(item);
            }

            ctx.SaveChanges();
            ctx.Dispose();

            return(componente);
        }
Esempio n. 5
0
        public List <Componente> BuscarComponentesPorAreaAtuacao(string areaAtuacao)
        {
            List <int> listaidAreaAtuacao = new List <int>();

            var listaId = areaAtuacao.Split(',');

            foreach (var s in listaId)
            {
                listaidAreaAtuacao.Add(int.Parse(s));
            }

            var ctx = new SPEContext();

            ctx.Configuration.LazyLoadingEnabled   = false;
            ctx.Configuration.ProxyCreationEnabled = false;
            var componentes = (from u in ctx.Componente.Include("AreaAtuacao")
                               where u.AreaAtuacao.Count(v => listaidAreaAtuacao.Contains(v.IdAreaAtuacao)) > 0

                               select u).ToList();

            foreach (Componente componente in componentes)
            {
                foreach (var z in componente.AreaAtuacao)
                {
                    z.Componente = null;
                }
            }
            return(componentes);
        }
Esempio n. 6
0
        public void Atualizar(Perfil model, List <int> IdFuncionalidades)
        {
            this.Update(model);
            this.Save();
            var ctx = new SPEContext();

            ctx.Configuration.LazyLoadingEnabled   = false;
            ctx.Configuration.ProxyCreationEnabled = false;
            List <Funcionalidade> lista = new List <Funcionalidade>();

            foreach (var item in IdFuncionalidades)
            {
                lista.Add(ctx.Funcionalidade.Where(a => a.idFuncionalidade == item).FirstOrDefault());
            }
            var PerfilFuncionalidade = (from u in ctx.Perfil.Include("Funcionalidade")
                                        where u.idPerfil == model.idPerfil
                                        select u).SingleOrDefault();

            if (PerfilFuncionalidade != null && PerfilFuncionalidade.Funcionalidade.Count > 0)
            {
                foreach (var item in PerfilFuncionalidade.Funcionalidade.ToList())
                {
                    PerfilFuncionalidade.Funcionalidade.Remove(item);
                }
            }
            PerfilFuncionalidade.Funcionalidade = lista;
            ctx.SaveChanges();
            ctx.Dispose();
            Save();
        }
Esempio n. 7
0
        public void AtualizarTurma(Turma turma)
        {
            //perfil.DataAlteracao = DateTime.Now.AddHours(-3);
            //perfil.UsuarioAlteracaoId = this.UsuarioLogado.Id;

            if (turma.Aprovado != null)
            {
                var ctx = new SPEContext();
                ctx.Configuration.LazyLoadingEnabled   = false;
                ctx.Configuration.ProxyCreationEnabled = false;

                var turmaOriginal = GetById(turma.IdTurma);
                turmaOriginal.Aprovado = turma.Aprovado;

                Update(turmaOriginal);
                ctx.SaveChanges();
                ctx.Dispose();
                Save();
            }
            else
            {
                var turmaOriginal = this.Get(e => e.IdTurma == turma.IdTurma, null, "AgendaAmbiente,AgendaComponente,AgendaDocente").SingleOrDefault();

                if (turmaOriginal.IdMatriz != turma.IdMatriz)
                {
                    var ListaAgendaAmbiente             = turmaOriginal.AgendaAmbiente.ToList();
                    var ListaAgendaComponente           = turmaOriginal.AgendaComponente.ToList();
                    var ListaAgendaDocente              = turmaOriginal.AgendaDocente.ToList();
                    AgendaAmbienteBL agendaAmbienteBL   = new AgendaAmbienteBL();
                    ComponenteBL     agendaComponenteBL = new ComponenteBL();
                    AgendaDocenteBL  agendaDocenteBL    = new AgendaDocenteBL();

                    turma.DataFim    = null;
                    turma.DataInicio = null;

                    foreach (var item in ListaAgendaAmbiente)
                    {
                        agendaAmbienteBL.Delete(item);
                    }

                    foreach (var item in ListaAgendaComponente)
                    {
                        agendaComponenteBL.Delete(item.IdAgendaComponente);
                    }

                    foreach (var item in ListaAgendaDocente)
                    {
                        agendaDocenteBL.Delete(item);
                    }

                    //turmaOriginal.AgendaAmbiente.Clear();
                    //turmaOriginal.AgendaComponente.Clear();
                    //turmaOriginal.AgendaDocente.Clear();
                }

                //turmaOriginal = turma;
                Update(turma);
            }
        }
Esempio n. 8
0
        public void RemoverModulos(int p = 0)
        {
            var ctx = new SPEContext();

            ctx.Configuration.LazyLoadingEnabled   = false;
            ctx.Configuration.ProxyCreationEnabled = false;

            MatrizBL matrizBL = new MatrizBL();
            var      matriz   =
                ctx.Matriz.Include("Modulo")
                .Include("Modulo.Componente")
                .Include("Modulo.AgendaDocente")
                .Include("Modulo.AgendaComponente")
                .Include("Modulo.AgendaAmbiente")
                .Where(e => e.IdMatriz == p);
            var modulos = matriz.FirstOrDefault().Modulo;

            var teste = modulos.ToList();

            foreach (var item in teste)
            {
                if (item.AgendaComponente.Count > 0 || item.AgendaAmbiente.Count > 0 || item.AgendaDocente.Count > 0)
                {
                    throw new CustomException("Erro ao editar Matriz. Esse Matriz está encontra-se com agendamentos, não podendo ser editada.");
                }
            }


            if (teste.Count > 0)
            {
                foreach (Modulo modulo in teste.ToList())
                {
                    if (modulo.Componente.Any())
                    {
                        modulo.Componente = null;
                    }
                }

                matriz.FirstOrDefault().Modulo = modulos;
                ctx.SaveChanges();

                Delete(teste);
                this.Save();
            }
        }
Esempio n. 9
0
        public void AtualizarReprovacaoMatriz(Matriz matriz, DateTime date, string observ = "")
        {
            //perfil.DataAlteracao = DateTime.Now.AddHours(-3);
            //perfil.UsuarioAlteracaoId = this.UsuarioLogado.Id;
            var existe2 = Get(e => string.Compare(e.Nome.ToLower(), matriz.Nome.ToLower(), CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace) == 0 &&
                              e.CH == matriz.CH).ToList();

            var existe = Get(e => string.Compare(e.Nome.ToLower(), matriz.Nome.ToLower(), CultureInfo.CurrentCulture, CompareOptions.IgnoreNonSpace) == 0 &&
                             e.CH == matriz.CH &&
                             e.IdMatriz != matriz.IdMatriz);

            if (existe.ToList().Count > 0)
            {
                throw new CustomException("Erro ao cadastrar Matriz. Já existe uma Matriz cadastrada com esse Nome e CH.");
            }

            this.Update(matriz);
            this.Save();
            var ctx = new SPEContext();

            ctx.Configuration.LazyLoadingEnabled   = false;
            ctx.Configuration.ProxyCreationEnabled = false;
            ReprovacaoMatriz RepMatriz = new ReprovacaoMatriz
            {
                IdMatriz   = matriz.IdMatriz,
                Observacao = observ,
                Data       = date,
                Tipo       = matriz.Aprovado
            };

            ctx.ReprovacaoMatriz.Add(RepMatriz);
            ctx.SaveChanges();
            ctx.Dispose();
            Save();


            Update(matriz);
        }