Esempio n. 1
0
        public new static bool Delete
        (
            Autenticador.Entities.SYS_TipoEntidade entity
        )
        {
            SYS_TipoEntidadeDAO dal = new SYS_TipoEntidadeDAO();

            dal._Banco.Open(IsolationLevel.ReadCommitted);

            try
            {
                //Verifica se o tipo de entidade pode ser deletado
                if (dal.Select_Integridade(entity.ten_id) > 0)
                {
                    throw new Exception("Não é possível excluir o tipo de entidade pois possui outros registros ligados a ele.");
                }
                else
                {
                    //Deleta logicamente o tipo de entidade
                    dal.Delete(entity);
                }

                return(true);
            }
            catch (Exception err)
            {
                dal._Banco.Close(err);
                throw;
            }
            finally
            {
                dal._Banco.Close();
            }
        }
Esempio n. 2
0
        public static bool VerificaNomeExistente(Autenticador.Entities.SYS_TipoEntidade entity)
        {
            SYS_TipoEntidadeDAO dal = new SYS_TipoEntidadeDAO();

            try
            {
                return(dal.SelectBy_Nome(entity.ten_id, entity.ten_nome));
            }
            catch
            {
                throw;
            }
        }
Esempio n. 3
0
        public new static bool Save(Autenticador.Entities.SYS_TipoEntidade entity)
        {
            SYS_TipoEntidadeDAO dal = new SYS_TipoEntidadeDAO();

            dal._Banco.Open(IsolationLevel.ReadCommitted);

            try
            {
                if (entity.Validate())
                {
                    if (VerificaNomeExistente(entity))
                    {
                        throw new DuplicateNameException("Já existe um tipo de entidade cadastrado com este nome.");
                    }
                    else
                    {
                        dal.Salvar(entity);
                    }
                }
                else
                {
                    throw new CoreLibrary.Validation.Exceptions.ValidationException(entity.PropertiesErrorList[0].Message);
                }

                return(true);
            }
            catch (Exception err)
            {
                dal._Banco.Close(err);
                throw;
            }
            finally
            {
                dal._Banco.Close();
            }
        }