Ejemplo n.º 1
0
 public long CountNumerosOficiais(string texto)
 {
     try
     {
         var spec = NumeroOficialSpecification.ConsultaTexto(texto);
         return(_numeroOficialRepository.Count(spec));
     }
     catch (Exception ex)
     {
         throw ManipuladorDeExcecao.TrateExcecao(ex);
     }
 }
Ejemplo n.º 2
0
        public List <NumeroOficialListDTO> FindNumerosOficiais <KProperty>(string texto, Expression <Func <NumeroOficial, KProperty> > orderByExpression, bool ascending, int pageIndex, int pageCount)
        {
            try
            {
                var spec = NumeroOficialSpecification.ConsultaTexto(texto);
                List <NumeroOficial> numerosOficiais = _numeroOficialRepository.GetPaged <KProperty>(pageIndex, pageCount, spec, orderByExpression, ascending).ToList();

                var adapter = TypeAdapterFactory.CreateAdapter();
                return(adapter.Adapt <List <NumeroOficial>, List <NumeroOficialListDTO> >(numerosOficiais));
            }
            catch (Exception ex)
            {
                throw ManipuladorDeExcecao.TrateExcecao(ex);
            }
        }
Ejemplo n.º 3
0
        private void AlterarNumeroOficial(NumeroOficial persistido, NumeroOficial corrente)
        {
            var validator = EntityValidatorFactory.CreateValidator();

            if (!validator.IsValid(corrente))
            {
                throw new AppException(validator.GetInvalidMessages <NumeroOficial>(corrente));
            }

            var specExisteNumeroOficial = NumeroOficialSpecification.ConsultaTexto(corrente.Requerente);

            if (_numeroOficialRepository.AllMatching(specExisteNumeroOficial).Where(c => c.Id != persistido.Id).Any())
            {
                throw new AppException("Já existe um número Oficial cadastrado com este nome.");
            }

            _numeroOficialRepository.Merge(persistido, corrente);
            _numeroOficialRepository.Commit();
        }
Ejemplo n.º 4
0
        public NumeroOficialDTO FindNumeroOficial(string requerente)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(requerente))
                {
                    throw new AppException("Informe o nome do requerente.");
                }

                var spec          = NumeroOficialSpecification.ConsultaTexto(requerente);
                var numeroOficial = _numeroOficialRepository.AllMatching(spec).SingleOrDefault();
                if (numeroOficial == null)
                {
                    throw new AppException("NumeroOficial não encontrada.");
                }

                var adapter = TypeAdapterFactory.CreateAdapter();
                return(adapter.Adapt <NumeroOficial, NumeroOficialDTO>(numeroOficial));
            }
            catch (Exception ex)
            {
                throw ManipuladorDeExcecao.TrateExcecao(ex);
            }
        }