public async Task Vote(PlanningRound round, PlanningUser user, PlanningCard card) { round = _repository.GetById(round.Id); var vote = new PlanningVote { Id = Guid.NewGuid(), RoundId = round.Id, Card = card, User = user }; round.Votes.AddOrUpdate(vote); _repository.Update(round); var room = _roomRepository.GetById(round.RoomId); if (room == null) { return; } if (room.Users.Count == round.Votes.Count) { await ShowAllVotes(round.Id); } await Clients.All.SendAsync("onUserVoted", vote); }
public void Update(PlanningRound entity) { if (!_rounds.ContainsKey(entity.Id)) { return; } _rounds[entity.Id] = entity; }
public async Task NewRound(Guid roomId, Guid startedBy) { var round = new PlanningRound { Id = Guid.NewGuid(), RoomId = roomId, StartedById = startedBy, TimeTaken = TimeSpan.Zero }; _repository.Insert(round); var room = _roomRepository.GetById(roomId); var connections = room.Users.Select(user => user.ConnectionId); _roundTimersStorage.StartNew(round.Id, connections); await Clients.All.SendAsync("onNewRoundStarted", round); }
public void Insert(PlanningRound entity) { _rounds.TryAdd(entity.Id, entity); }