public void Consume(LobbyCreated e) { var collection = _database.GetCollection <LobbyDTO>("LobbyDTOs"); var lobbyDTO = new LobbyDTO { Id = e.LobbyId, GameId = e.GameId, GameName = e.GameName, HostId = e.HostId, HostName = e.HostName }; collection.Save(lobbyDTO); }
public async Task <ActionResult <LobbyDTO> > GetByCode([FromQuery] GetLobbyByCodeQuery query) { var lobby = await _mediator.Send(query); var reconnect = lobby.Players.Find(player => player.Name == query.Player); var response = new LobbyDTO { Players = lobby.ActivePlayers?.Select(player => new PlayerDTO { Name = player.Name, Score = player.Score }).ToList(), RoundNumber = lobby.RoundNumber, GameState = lobby.GameState.DisplayName, CurrentStoryTeller = lobby.CurrentStoryTeller?.Name, StoryCard = lobby.CurrentStoryCard?.Id ?? 0, Story = lobby.CurrentStory, Cards = lobby.CurrentPlayedCards?.Select(card => card.Id).ToList(), Votes = lobby.CurrentVotes?.Select(vote => new VoteDTO { Card = vote.Card.Id, Player = vote.Player.Name }).ToList(), Hand = lobby.Deck.Hand(reconnect)?.Select(card => card.Id).ToList() }; return(response); }
public string NewLobby([FromUri] List<string> paramArray) { if (paramArray.Capacity > 0) { String[] l = paramArray[0].Split(','); LobbyDTO lobbyobject = new LobbyDTO(Int32.Parse(l[0]), l[1], DateTime.Parse(l[2]), Int32.Parse(l[3])); try { LobbyLogic.AddLobby(lobbyobject.GameId, lobbyobject.NrOfPlayers, lobbyobject.StartTime, lobbyobject.CreatorName); } catch(Exception ex) { return "Az error occured!" + ex; } return "recieved an object!"; } return "NOTHING RECIEVED..."; }