Example #1
0
        public new static bool Save(Autenticador.Entities.PES_TipoEscolaridade entity)
        {
            PES_TipoEscolaridadeDAO dal = new PES_TipoEscolaridadeDAO();

            dal._Banco.Open(IsolationLevel.ReadCommitted);

            try
            {
                if (entity.Validate())
                {
                    if (VerificaNomeExistente(entity))
                    {
                        throw new DuplicateNameException("Já existe um tipo de escolaridade cadastrado com este nome.");
                    }
                    else
                    {
                        dal.Salvar(entity);

                        if (entity.IsNew)
                        {
                            entity.tes_ordem = dal.SelectMAX_tes_ordem();
                            entity.IsNew     = false;
                            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();
            }
        }
Example #2
0
        public static bool SaveOrdem
        (
            Autenticador.Entities.PES_TipoEscolaridade entityDescer
            , Autenticador.Entities.PES_TipoEscolaridade entitySubir
        )
        {
            PES_TipoEscolaridadeDAO dal = new PES_TipoEscolaridadeDAO();

            dal._Banco.Open(IsolationLevel.ReadCommitted);

            try
            {
                if (entityDescer.Validate())
                {
                    dal.Salvar(entityDescer);
                }
                else
                {
                    throw new CoreLibrary.Validation.Exceptions.ValidationException(entityDescer.PropertiesErrorList[0].Message);
                }

                if (entitySubir.Validate())
                {
                    dal.Salvar(entitySubir);
                }
                else
                {
                    throw new CoreLibrary.Validation.Exceptions.ValidationException(entitySubir.PropertiesErrorList[0].Message);
                }

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