Пример #1
0
        protected internal override void FillParameters(ref CidadeDto pDto, ref DBParameter pParameter, ExecutionTypes pExecutionType)
        {
            try
            {
                switch (pExecutionType)
                {
                case ExecutionTypes.Get:
                case ExecutionTypes.Update:
                case ExecutionTypes.Delete:
                    pParameter.AddParameter("CidadeId", pDto.CidadeId, SqlDbType.Int, ParameterDirection.Input);
                    break;
                }

                switch (pExecutionType)
                {
                case ExecutionTypes.GetByParameters:
                case ExecutionTypes.Insert:
                case ExecutionTypes.Update:
                    if (pDto.UnidadeFederacaoId > 0)
                    {
                        pParameter.AddParameter("UnidadeFederacaoId", pDto.UnidadeFederacaoId, SqlDbType.Int, ParameterDirection.Input);
                    }

                    if (!string.IsNullOrWhiteSpace(pDto.Nome))
                    {
                        pParameter.AddParameter("Nome", pDto.Nome, SqlDbType.VarChar, ParameterDirection.Input, 255);
                    }

                    if (!string.IsNullOrWhiteSpace(pDto.DDD))
                    {
                        pParameter.AddParameter("DDD", pDto.DDD, SqlDbType.VarChar, ParameterDirection.Input, 255);
                    }

                    if (!string.IsNullOrWhiteSpace(pDto.CEPInicial))
                    {
                        pParameter.AddParameter("CEPInicial", pDto.CEPInicial, SqlDbType.VarChar, ParameterDirection.Input, 255);
                    }

                    if (!string.IsNullOrWhiteSpace(pDto.CEPFinal))
                    {
                        pParameter.AddParameter("CEPFinal", pDto.CEPFinal, SqlDbType.VarChar, ParameterDirection.Input, 255);
                    }

                    if (!string.IsNullOrWhiteSpace(pDto.Classe))
                    {
                        pParameter.AddParameter("Classe", pDto.Classe, SqlDbType.VarChar, ParameterDirection.Input, 255);
                    }

                    break;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Erro ao preencher parametros do objeto Cidade. Motivo: " + ex.Message);
            }
        }