public async Task <GameStartStatus> StartGame() { var user = GetUser(); var storage = context.Storage; var room = (await storage.Get <Room>(r => r.Players.Contains(user))).SingleOrDefault(); if (room == null) { return(GameStartStatus.NotInRoom); } else if (!string.IsNullOrEmpty(room.GameId)) { return(GameStartStatus.GameInProgress); } else if (!user.Equals(room.Owner)) { return(GameStartStatus.NotAnOwner); } else if (room.Players.Count < 2) { return(GameStartStatus.NotEnoughPlayers); } else { var gameId = await starter.StartGame(room.GameType, room.Players.Select(player => player.Username)); room.GameId = gameId; await storage.Save(room); return(GameStartStatus.OK); } }