示例#1
0
        public async Task <IActionResult> Get(int id)
        {
            var responseContent = new ResponseContent();

            try
            {
                responseContent.Object = await _restauranteBLL.GetRestauranteByIdAsync(id);

                if (responseContent.Object == null)
                {
                    responseContent.Message = "A pesquisa não retornou dados";
                    return(NotFound(responseContent));
                }
                responseContent.Message = "Operação realizada com sucesso!!";
                return(Ok(responseContent));
            }
            catch (BusinessException bex)
            {
                responseContent.Message = bex.Message;
                return(BadRequest(responseContent));
            }
            catch (Exception ex)
            {
                responseContent.Message = ex.Message;
                return(BadRequest(responseContent));
            }
        }
示例#2
0
        public async Task <Restaurante> GetResultadoVotoDiarioAsync(int idTurma)       //// resultado da votação
        {
            var ultimoPeriodoTurma = await _periodoBLL.GetUltimoPeriodoAsync(idTurma); // pega idPeriodo

            var periodoDiario = await _periodoDiarioBLL.GetUltimoPeriodoDiarioAsync(ultimoPeriodoTurma.IDPeriodo);

            await _periodoDiarioBLL.FecharPeriodoDiario(ultimoPeriodoTurma.IDPeriodo);//fecha o período

            if (await _periodoDiarioBLL.IsPeriodoAbertoAsync(periodoDiario.IDPeriodoDiario))
            {
                var msg = "O periodo de votação ainda está aberto";
                throw new Exception(msg);
            }
            else
            {
                var idPeriodoResultado = _votoDiarioRepository.GetResultadoVotoDiarioAsync(periodoDiario.IDPeriodoDiario);
                var periodoResultado   = await _periodoResultadoBLL.GetPeriodo(idPeriodoResultado);

                await _periodoResultadoBLL.UpdateSNVisitado(periodoResultado.IDPeriodoResultado);

                return(await _restauranteBLL.GetRestauranteByIdAsync(periodoResultado.IDRestaurante)); // restaurante
            }
        }