public long CountResponsaveis(string texto) { try { var spec = ResponsavelSpecification.ConsultaTexto(texto); return(_responsavelRepository.Count(spec)); } catch (Exception ex) { throw ManipuladorDeExcecao.TrateExcecao(ex); } }
public List <ResponsavelListDTO> FindResponsaveis <KProperty>(string texto, Expression <Func <Responsavel, KProperty> > orderByExpression, bool ascending, int pageIndex, int pageCount) { try { var spec = ResponsavelSpecification.ConsultaTexto(texto); List <Responsavel> Responsaveis = _responsavelRepository.GetPaged <KProperty>(pageIndex, pageCount, spec, orderByExpression, ascending).ToList(); var adapter = TypeAdapterFactory.CreateAdapter(); return(adapter.Adapt <List <Responsavel>, List <ResponsavelListDTO> >(Responsaveis)); } catch (Exception ex) { throw ManipuladorDeExcecao.TrateExcecao(ex); } }
public async override Task <IEnumerable <ResponsavelQueryViewModel> > HandleAsync(GetResponsaveisQuery request) { var skip = request.Skip ?? 0; var take = request.Take ?? 10; var processos = await _repository.Responsaveis .Include(a => a.ProcessoResponsaveis) .ThenInclude(a => a.Processo) .Where(ResponsavelSpecification.ResponsavelNome(request.Nome)) .Where(ResponsavelSpecification.ResponsavelCPF(request.CPF)) .Where(ResponsavelSpecification.ResponsavelNumeroProcessoUnificado(request.NumeroProcessoUnificado)) .Skip(skip) .Take(take) .Select(p => p.ToQueryViewModel()) .ToListAsync(); return(processos); }
private void AlterarResponsavel(Responsavel persistido, Responsavel corrente) { var validator = EntityValidatorFactory.CreateValidator(); if (!validator.IsValid(corrente)) { throw new AppException(validator.GetInvalidMessages <Responsavel>(corrente)); } var specExisteResponsavel = ResponsavelSpecification.ConsultaTexto(corrente.Nome); if (_responsavelRepository.AllMatching(specExisteResponsavel).Where(c => c.Id != persistido.Id).Any()) { throw new AppException("Já existe um responsável cadastrado com este nome."); } _responsavelRepository.Merge(persistido, corrente); _responsavelRepository.Commit(); }
private void SalvarResponsavel(Responsavel responsavel) { var validator = EntityValidatorFactory.CreateValidator(); if (!validator.IsValid(responsavel)) { throw new AppException(validator.GetInvalidMessages <Responsavel>(responsavel)); } var specExisteResponsavel = ResponsavelSpecification.ConsultaTexto(responsavel.Nome); if (_responsavelRepository.AllMatching(specExisteResponsavel).Any()) { throw new AppException("Já existe um responsável cadastrado com este nome."); } _responsavelRepository.Add(responsavel); _responsavelRepository.Commit(); }
public ResponsavelDTO FindResponsavel(string nomeResponsavel) { try { if (string.IsNullOrWhiteSpace(nomeResponsavel)) { throw new AppException("Informe o nome de responsavel."); } var spec = ResponsavelSpecification.ConsultaTexto(nomeResponsavel); var Responsavel = _responsavelRepository.AllMatching(spec).SingleOrDefault(); if (Responsavel == null) { throw new AppException("Responsável não encontrado."); } var adapter = TypeAdapterFactory.CreateAdapter(); return(adapter.Adapt <Responsavel, ResponsavelDTO>(Responsavel)); } catch (Exception ex) { throw ManipuladorDeExcecao.TrateExcecao(ex); } }