Exemplo n.º 1
0
        public async Task ConfirmarAsync(string usuario, string senha, int restauranteId)
        {
            Task <Aluno> aluno = _alunoRepository.AutenticarAsync(usuario, senha);

            if (aluno.Result == null)
            {
                throw new BusinessException("Usuário ou Senha Inválidos");
            }

            Task <Voto> votoAluno = _votoRepository.VotoDoAluno(DateTime.Now.Date, aluno.Result.Id);

            if (votoAluno.Result != null && votoAluno.Result.Id > 0)
            {
                throw new BusinessException("Usuário já votou");
            }

            if (DateTime.Now.Hour >= 12)
            {
                throw new BusinessException("Votação encerrada");
            }

            Task <Restaurante> restaurante = _restauranteRepository.GetByIdAsync(restauranteId);

            if (restaurante.Result == null)
            {
                throw new BusinessException("Restaurante não encontrado");
            }

            _votoRepository.ConfirmarAsync(aluno.Result, restaurante.Result);
            await _votoRepository.UnitOfWork.Commit();
        }
Exemplo n.º 2
0
 public async Task <Aluno> AutenticarAsync(string usuario, string senha)
 {
     return(await _alunoRepository.AutenticarAsync(usuario, senha));
 }