public async Task <bool> HasEntrevistas(string userName) { var entrevistadorSpecificaciones = new EntrevistaSpecification(userName); var entrevistasAsignadas = await this.entrevistaRepository.ListAsync(entrevistadorSpecificaciones) .ConfigureAwait(false); return(entrevistasAsignadas.Any()); }
public long CountEntrevistas(string texto) { try { var spec = EntrevistaSpecification.ConsultaTexto(texto); return(_entrevistaRepository.Count(spec)); } catch (Exception ex) { throw ManipuladorDeExcecao.TrateExcecao(ex); } }
public List <EntrevistaListDTO> FindEntrevistas <KProperty>(string texto, Expression <Func <Entrevista, KProperty> > orderByExpression, bool ascending, int pageIndex, int pageCount) { try { var spec = EntrevistaSpecification.ConsultaTexto(texto); List <Entrevista> Entrevistas = _entrevistaRepository.GetPaged <KProperty>(pageIndex, pageCount, spec, orderByExpression, ascending).ToList(); var adapter = TypeAdapterFactory.CreateAdapter(); return(adapter.Adapt <List <Entrevista>, List <EntrevistaListDTO> >(Entrevistas)); } catch (Exception ex) { throw ManipuladorDeExcecao.TrateExcecao(ex); } }
private void AlterarEntrevista(Entrevista persistido, Entrevista corrente) { var validator = EntityValidatorFactory.CreateValidator(); if (!validator.IsValid(corrente)) { throw new AppException(validator.GetInvalidMessages <Entrevista>(corrente)); } var specExisteEntrevista = EntrevistaSpecification.ConsultaTexto(corrente.NomeDaEmpresa1); if (_entrevistaRepository.AllMatching(specExisteEntrevista).Where(c => c.Id != persistido.Id).Any()) { throw new AppException("Já existe uma entrevista cadastrada com este nome."); } _entrevistaRepository.Merge(persistido, corrente); _entrevistaRepository.Commit(); }
private void SalvarEntrevista(Entrevista entrevista) { var validator = EntityValidatorFactory.CreateValidator(); if (!validator.IsValid(entrevista)) { throw new AppException(validator.GetInvalidMessages <Entrevista>(entrevista)); } var specExisteEntrevista = EntrevistaSpecification.ConsultaTexto(entrevista.NomeDaEmpresa1); if (_entrevistaRepository.AllMatching(specExisteEntrevista).Any()) { throw new AppException("Já existe uma entrevista cadastrada com este nome."); } _entrevistaRepository.Add(entrevista); _entrevistaRepository.Commit(); }
public EntrevistaDTO FindEntrevista(string nomeDaEmpresa1) { try { if (string.IsNullOrWhiteSpace(nomeDaEmpresa1)) { throw new AppException("Informe o nome do primeiro sócio."); } var spec = EntrevistaSpecification.ConsultaTexto(nomeDaEmpresa1); var Entrevista = _entrevistaRepository.AllMatching(spec).SingleOrDefault(); if (Entrevista == null) { throw new AppException("Entrevista não encontrada."); } var adapter = TypeAdapterFactory.CreateAdapter(); return(adapter.Adapt <Entrevista, EntrevistaDTO>(Entrevista)); } catch (Exception ex) { throw ManipuladorDeExcecao.TrateExcecao(ex); } }