コード例 #1
0
 public IEnumerable <Participante> GetAllGeral(TipoCota cota)
 {
     return(_context.Participantes
            .AsNoTracking()
            .Where(ParticipanteQueries.GetAllGeral(cota))
            .OrderBy(x => x.Nome));
 }
コード例 #2
0
        public int GetAllValid()
        {
            var idosos = _context.Participantes.Where(ParticipanteQueries.GetAllIdoso(TipoCota.Idoso)).Count();
            var pcds   = _context.Participantes.Where(ParticipanteQueries.GetAllPcd(TipoCota.PcD)).Count();
            var gerais = _context.Participantes.Where(ParticipanteQueries.GetAllGeral(TipoCota.Geral)).Count();

            return(idosos + pcds + gerais);
        }
コード例 #3
0
        public List <Participante> GetWinnerGeral(TipoCota cota, int qtd)
        {
            Random rdn = new Random();
            List <Participante>        sorteados = new List <Participante>();
            Participante               sorteado  = new Participante();
            IEnumerable <Participante> lista     = _context.Participantes
                                                   .AsNoTracking()
                                                   .Where(ParticipanteQueries.GetAllGeral(cota));

            for (int i = 1; i <= qtd; i++)
            {
                var result = lista.Where(p => sorteados.All(p2 => p2.Cpf != p.Cpf)).OrderBy(x => rdn.Next()).FirstOrDefault();
                if (result != null)
                {
                    sorteados.Add(result);
                }
            }
            return(sorteados);
        }
コード例 #4
0
        public void Deve_retornar_participantes_da_cota_geral_e_validos()
        {
            var result = _participantes.AsQueryable().Where(ParticipanteQueries.GetAllGeral(TipoCota.Geral));

            Assert.AreEqual(1, result.Count());
        }