Esempio n. 1
0
        /// <summary>
        /// Remover detento pelo id.
        /// </summary>
        /// <param name="id">Identificação no sistema</param>
        public static void Remover(int id)
        {
            using (ObservatorioEntities context = new ObservatorioEntities())
            {
                //Consulta processos do detento
                var processo_ = from Processo p in context.Processos
                                where p.Detento.Id == id
                                select p;

                if (processo_.Count() > 0)
                {
                    string processosId = "";
                    foreach (Processo p in processo_)
                    {
                        processosId += " " + p.Id;
                    }
                    throw new NegocioException(NegocioExcCode.DETENTOPOSSUIPROCESSO,
                                               "[" + processosId + "]");
                }

                var detento_ = from Detento d in context.Detentos
                               where d.Id == id
                               select d;

                if (detento_.Count() > 0)
                {
                    context.Detentos.Remove(detento_.First());
                    context.SaveChanges();
                }
                else
                {
                    throw new NegocioException(NegocioExcCode.DETENTOIDNAOENCONTRADO, id.ToString());
                }
            }
        }
Esempio n. 2
0
        public static void Atualizar(int id, string nome, string genitor, string genitora,
                                     string RG, string CPF, int qtdeFilhos, bool possuiMenor, string anotacoes)
        {
            if (genitora == null || genitora.Length == 0)
            {
                throw new NegocioException(NegocioExcCode.DETENTOGENITORAOBRIGATORIA, "");
            }

            using (ObservatorioEntities context = new ObservatorioEntities())
            {
                var detento_ = from Detento d in context.Detentos
                               where d.Id == id
                               select d;

                if (detento_.Count() > 0)
                {
                    Detento d = detento_.First();
                    d.Nome        = nome;
                    d.Genitor     = genitor;
                    d.Genitora    = genitora;
                    d.RG          = RG;
                    d.CPF         = CPF;
                    d.QtdeFilhos  = qtdeFilhos;
                    d.PossuiMenor = possuiMenor;
                    d.Anotacoes   = anotacoes;

                    context.SaveChanges();
                }
            }
        }
Esempio n. 3
0
        public static void RemoverProcesso(int idProcesso)
        {
            using (ObservatorioEntities context = new ObservatorioEntities())
            {
                var processo_ = from Processo p in context.Processos
                                where p.Id == idProcesso
                                select p;

                if (processo_.Count() == 0)
                {
                    throw new NegocioException(NegocioExcCode.PROCESSONAOENCONTRADO, idProcesso.ToString());
                }

                var acomp_ = from Acompanhamento a in context.Acompanhamentos
                             where a.Processo.Id == idProcesso
                             select a;

                if (acomp_.Count() > 0)
                {
                    throw new NegocioException(NegocioExcCode.PROCESSOPOSSUIACOMP, processo_.First().Numero);
                }

                context.Processos.Remove(processo_.First());
                context.SaveChanges();
            }
        }
        public static List <Usuario> Listar()
        {
            List <Usuario> usuarios = null;

            using (ObservatorioEntities context = new ObservatorioEntities())
            {
                usuarios = context.Usuarios.ToList();
            }
            return(usuarios);
        }
Esempio n. 5
0
        public static List <Processo> Listar()
        {
            List <Processo> processo = null;

            using (ObservatorioEntities context = new ObservatorioEntities())
            {
                processos = context.Processos.ToList();
            }
            return(processos);
        }
        public static void Inserir(string nome)
        {
            using (ObservatorioEntities context = new ObservatorioEntities())
            {
                Usuario d = new Usuario();
                d.Nome = nome;

                context.Usuarios.Add(d);
                context.SaveChanges();
            }
        }
Esempio n. 7
0
        public static void Inserir(int numero, DateTime date)
        {
            using (ObservatorioEntities context = new ObservatorioEntities())
            {
                Processo p = new Processo();
                p.Numero     = numero;
                p.DataInicio = date;

                context.Processos.Add(p);
                context.SaveChanges();
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Lista detentos com filtro de nome e genitora
        /// </summary>
        /// <returns></returns>
        public static List <Detento> Listar(string nome, string genitora)
        {
            List <Detento> detentos = new List <Detento>();

            using (ObservatorioEntities context = new ObservatorioEntities())
            {
                var detentos_ = from Detento d in context.Detentos
                                where d.Nome.Contains(nome) && d.Genitora.Contains(genitora)
                                select d;

                detentos.AddRange(detentos_.ToList());
            }
            return(detentos);
        }
        public static void Atualizar(int id, string nome)
        {
            using (ObservatorioEntities context = new ObservatorioEntities())
            {
                var usuario_ = from Usuario d in context.Usuarios
                               where d.Id == id
                               select d;

                if (usuario_.Count() > 0)
                {
                    usuario_.First().Nome = nome;
                    context.SaveChanges();
                }
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Retorna a lista de processos de um detento.
        /// </summary>
        /// <param name="idDetento"></param>
        /// <returns></returns>
        public List <Processo> ListarProcessosPorDetento(int idDetento)
        {
            List <Processo> processos = new List <Processo>();

            using (ObservatorioEntities context = new ObservatorioEntities())
            {
                var processo_ = from Processo p in context.Processos
                                where p.Detento.Id == idDetento
                                select p;

                processos.AddRange(processo_);
            }

            return(processos);
        }
Esempio n. 11
0
        public static void Atualizar(int id, int numero, DateTime date)
        {
            using (ObservatorioEntities context = new ObservatorioEntities())
            {
                var processo_ = from Processo p in context.Processos
                                where p.Id == id
                                select p;

                if (processo_.Count() > 0)
                {
                    processo_.First().Numero     = numero;
                    processo_.First().DataInicio = date;
                    context.SaveChanges();
                }
            }
        }
Esempio n. 12
0
        public static Processo Consultar(int id)
        {
            Processo processo = null;

            using (ObservatorioEntities context = new ObservatorioEntities())
            {
                var processo_ = from Processo p in context.Processos
                                where p.Id == id
                                select p;

                if (processo_.Count() > 0)
                {
                    processo = processo_.First();
                }
            }
            return(processo);
        }
        public static Usuario Consultar(int id)
        {
            Usuario usuario = null;

            using (ObservatorioEntities context = new ObservatorioEntities())
            {
                var usuario_ = from Usuario d in context.Usuarios
                               where d.Id == id
                               select d;

                if (usuario_.Count() > 0)
                {
                    usuario = usuario_.First();
                }
            }
            return(usuario);
        }
Esempio n. 14
0
        /// <summary>
        /// Remover processo pelo id.
        /// </summary>
        /// <param name="id">Identificação no sistema</param>
        public static void Remover(int id)
        {
            using (ObservatorioEntities context = new ObservatorioEntities())
            {
                //CONSULTAR OS PROCESSOS ANTES DE REMOVER; GERA EXCEÇÃO SE EXISTIR


                var processo_ = from Processo p in context.Processos
                                where p.Id == id
                                select p;

                if (processo_.Count() > 0)
                {
                    context.Processos.Remove(processo_.First());
                    context.SaveChanges();
                }
            }
        }
        /// <summary>
        /// Remover detento pelo id.
        /// </summary>
        /// <param name="id">Identificação no sistema</param>
        public static void Remover(int id)
        {
            using (ObservatorioEntities context = new ObservatorioEntities())
            {
                //CONSULTAR OS PROCESSOS ANTES DE REMOVER; GERA EXCEÇÃO SE EXISTIR


                var usuario_ = from Usuario d in context.Usuarios
                               where d.Id == id
                               select d;

                if (usuario_.Count() > 0)
                {
                    context.Usuarios.Remove(usuario_.First());
                    context.SaveChanges();
                }
            }
        }
Esempio n. 16
0
        /// <summary>
        /// Consulta um detento pelo seu Id.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static Detento Consultar(int id)
        {
            Detento detento = null;

            using (ObservatorioEntities context = new ObservatorioEntities())
            {
                var detento_ = from Detento d in context.Detentos
                               where d.Id == id
                               select d;

                if (detento_.Count() > 0)
                {
                    detento = detento_.First();
                }
                else
                {
                    throw new NegocioException(NegocioExcCode.DETENTOIDNAOENCONTRADO, id.ToString());
                }
            }
            return(detento);
        }
Esempio n. 17
0
        public static void InserirProcesso(int idDetento, string numero, DateTime dataInicio,
                                           string anotacoes, int idJuizo)
        {
            if (numero == null || numero.Length == 0)
            {
                throw new NegocioException(NegocioExcCode.PROCESSONUMOBRIGATORIO, "");
            }

            using (ObservatorioEntities context = new ObservatorioEntities())
            {
                var detento_ = from Detento d in context.Detentos
                               where d.Id == idDetento
                               select d;

                if (detento_.Count() == 0)
                {
                    throw new NegocioException(NegocioExcCode.DETENTOIDNAOENCONTRADO, idDetento.ToString());
                }

                var juizo_ = from Juizo j in context.Juizos
                             where j.Id == idJuizo
                             select j;

                if (juizo_.Count() == 0)
                {
                    throw new NegocioException(NegocioExcCode.JUIZONAOENCONTRADO, idJuizo.ToString());
                }

                Processo p = new Processo();
                p.Numero     = numero;
                p.DataInicio = dataInicio;
                p.Detento    = detento_.First();
                p.Juizo      = juizo_.First();
                p.Anotacoes  = anotacoes;

                context.Processos.Add(p);
                context.SaveChanges();
            }
        }
Esempio n. 18
0
        public static void AtualizarProcesso(int idProcesso, string numero, DateTime dataInicio,
                                             string anotacoes, int idJuizo)
        {
            if (numero == null || numero.Length == 0)
            {
                throw new NegocioException(NegocioExcCode.PROCESSONUMOBRIGATORIO, "");
            }

            using (ObservatorioEntities context = new ObservatorioEntities())
            {
                var processo_ = from Processo p in context.Processos
                                where p.Id == idProcesso
                                select p;

                if (processo_.Count() == 0)
                {
                    throw new NegocioException(NegocioExcCode.PROCESSONAOENCONTRADO, idProcesso.ToString());
                }

                var juizo_ = from Juizo j in context.Juizos
                             where j.Id == idJuizo
                             select j;

                if (juizo_.Count() == 0)
                {
                    throw new NegocioException(NegocioExcCode.JUIZONAOENCONTRADO, idJuizo.ToString());
                }

                Processo p = processo_.First();
                p.Numero     = numero;
                p.DataInicio = dataInicio;
                p.Juizo      = juizo_.First();
                p.Anotacoes  = anotacoes;

                context.SaveChanges();
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Insere um novo detento.
        /// </summary>
        /// <param name="nome"></param>
        public static void Inserir(string nome, string genitor, string genitora,
                                   string RG, string CPF, int qtdeFilhos, bool possuiMenor, string anotacoes)
        {
            if (genitora == null || genitora.Length == 0)
            {
                throw new NegocioException(NegocioExcCode.DETENTOGENITORAOBRIGATORIA, "");
            }

            using (ObservatorioEntities context = new ObservatorioEntities())
            {
                Detento d = new Detento();
                d.Nome        = nome;
                d.Genitor     = genitor;
                d.Genitora    = genitora;
                d.RG          = RG;
                d.CPF         = CPF;
                d.QtdeFilhos  = qtdeFilhos;
                d.PossuiMenor = possuiMenor;
                d.Anotacoes   = anotacoes;

                context.Detentos.Add(d);
                context.SaveChanges();
            }
        }