public async override Task OnConnectedAsync() { Sorteio sorteioAtual = _sorteioAppService.ObterSorteioAtual(); if (sorteioAtual is null) { await Clients.Caller.SendAsync("aviso", "Não há sorteio ativo no momento"); await AtualizarSorteio(null); await base.OnConnectedAsync(); } await Clients.Caller.SendAsync("atualizarSorteio", _mapper.Map <Sorteio, SorteioViewModel>(sorteioAtual)); await base.OnConnectedAsync(); }
public ActionResult <SorteioViewModel> SorteioAtual() { try { var sorteio = _sorteioAppService.ObterSorteioAtual(); if (sorteio is null) { return(NotFound()); } return(Ok(_mapper.Map <Sorteio, SorteioViewModel>(sorteio))); } catch { return(BadRequest()); } }
public ActionResult <IEnumerable <SalaViewModel> > Salas() { var salas = _salaAppService.GetAll() .Where(s => s.Ativo) .Select(s => _mapper.Map <Sala, SalaViewModel>(s)); var sorteio = _sorteioAppService.ObterSorteioAtual(); if (sorteio == null) { return(Ok(salas.OrderBy(s => s.SalaId))); } return(Ok( salas.Select(s => { s.EstaNoSorteioAtual = s.SalaId == sorteio.SalaId; return s; }) .OrderBy(s => s.SalaId) )); }