public void Alterar(Bloqueado bloqueado)
        {
            try
            {
                Bloqueado bloqueadoAux = new Bloqueado();
                bloqueadoAux.id = bloqueado.id;


                List <Bloqueado> resultado = this.Consultar(bloqueadoAux, TipoPesquisa.E);

                if (resultado == null || resultado.Count == 0)
                {
                    throw new BloqueadoNaoAlteradoExcecao();
                }

                bloqueadoAux.cliente_id = bloqueado.cliente_id;
                bloqueadoAux.motivo     = bloqueado.motivo;
                //bloqueadoAux.timeCreated = bloqueado.timeCreated;
                //bloqueadoAux.timeUpdated = bloqueado.timeUpdated;
                bloqueadoAux.usuario_id = bloqueado.usuario_id;
                bloqueadoAux.id         = bloqueado.id;


                bloqueadoAux = resultado[0];

                Confirmar();
            }
            catch (Exception)
            {
                throw new BloqueadoNaoAlteradoExcecao();
            }
        }
 public void Incluir(Bloqueado bloqueado)
 {
     try
     {
         db.AddTobloqueado(bloqueado);
     }
     catch (Exception)
     {
         throw new BloqueadoNaoIncluidoExcecao();
     }
 }
        public List <Bloqueado> Consultar(Bloqueado bloqueado, TipoPesquisa tipoPesquisa)
        {
            List <Bloqueado> resultado = Consultar();

            switch (tipoPesquisa)
            {
                #region Case E
            case TipoPesquisa.E:
            {
                if (bloqueado.id != 0)
                {
                    resultado = ((from c in resultado
                                  where
                                  c.id == bloqueado.id
                                  select c).ToList());

                    resultado = resultado.Distinct().ToList();
                }



                break;
            }

                #endregion
                #region Case Ou
            case TipoPesquisa.Ou:
            {
                if (bloqueado.id != 0)
                {
                    resultado.AddRange((from c in Consultar()
                                        where
                                        c.id == bloqueado.id
                                        select c).ToList());
                    resultado = resultado.Distinct().ToList();
                }


                break;
            }

                #endregion
            default:
                break;
            }

            return(resultado);
        }
        public void Excluir(Bloqueado bloqueado)
        {
            try
            {
                Bloqueado bloqueadoAux = new Bloqueado();
                bloqueadoAux.id = bloqueado.id;


                List <Bloqueado> resultado = this.Consultar(bloqueadoAux, TipoPesquisa.E);

                if (resultado == null || resultado.Count == 0)
                {
                    throw new BloqueadoNaoExcluidoExcecao();
                }

                bloqueadoAux = resultado[0];

                db.DeleteObject(bloqueadoAux);
            }
            catch (Exception)
            {
                throw new BloqueadoNaoExcluidoExcecao();
            }
        }
Beispiel #5
0
        public void Excluir(Bloqueado bloqueado)
        {
            try
            {
                if (bloqueado.ID == 0)
                {
                    throw new BloqueadoNaoExcluidoExcecao();
                }

                List <Bloqueado> resultado = bloqueadoRepositorio.Consultar(bloqueado, TipoPesquisa.E);

                if (resultado == null || resultado.Count <= 0 || resultado.Count > 1)
                {
                    throw new BloqueadoNaoExcluidoExcecao();
                }

                this.bloqueadoRepositorio.Excluir(bloqueado);
            }
            catch (Exception e)
            {
                throw e;
            }
            //this.bloqueadoRepositorio.Excluir(bloqueado);
        }
Beispiel #6
0
        public List <Bloqueado> Consultar(Bloqueado bloqueado, TipoPesquisa tipoPesquisa)
        {
            List <Bloqueado> bloqueadoList = this.bloqueadoRepositorio.Consultar(bloqueado, tipoPesquisa);

            return(bloqueadoList);
        }
Beispiel #7
0
 public void Alterar(Bloqueado bloqueado)
 {
     this.bloqueadoRepositorio.Alterar(bloqueado);
 }
Beispiel #8
0
 public void Incluir(Bloqueado bloqueado)
 {
     this.bloqueadoRepositorio.Incluir(bloqueado);
 }