Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using System.Collections.Generic;
using System.Linq;
namespace MattEland.Starship.Logic
public class GameRepository
private readonly IList<GameState> _games = new List<GameState>();
public GameRepository()
// Start with some sample data
public IEnumerable<GameState> Games => _games;
public GameState GetGame(int id) => _games.FirstOrDefault(g => g.Id == id);
public GameState CreateNewGame()
int id = _games.Count + 1;
var game = new GameState(id);
return game;
public bool DeleteGame(int id)
var game = _games.FirstOrDefault(g => g.Id == id);
return game != null && _games.Remove(game);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.