Beispiel #1
0
 public ActionResult <SalaViewModel> Salas(int id)
 {
     try
     {
         var sala = _salaAppService.Get(id);
         if (sala is null)
         {
             return(NotFound());
         }
         return(Ok(_mapper.Map <Sala, SalaViewModel>(sala)));
     }
     catch
     {
         return(BadRequest());
     }
 }
        public async Task <ActionResult> IniciarSorteio(int SalaId)
        {
            try
            {
                var sala = _salaAppService.Get(SalaId);
                if (sala is null)
                {
                    return(BadRequest("Sala inválida"));
                }
                _sorteioAppService.IniciarNovoSorteio(sala);
                var sorteioAtual = _mapper.Map <Sorteio, SorteioViewModel>(_sorteioAppService.ObterSorteioAtual());
                await _sorteioHubConnection.AtualizarSorteio(sorteioAtual);

                await _sorteioHubConnection.AtualizarVencedores();

                await _sorteioHubConnection.AvisarTodos("Sorteio " + sorteioAtual.Sala.Nome + " iniciado");

                return(Ok(sorteioAtual));
            }
            catch
            {
                return(BadRequest());
            }
        }
Beispiel #3
0
        public ActionResult Edit(int id)
        {
            var sala = _mapper.Map <Sala, SalaViewModel>(_salaAppService.Get(id));

            return(View(sala));
        }