public HttpResponseMessage Get() { var games = _gameService.GetGames(User.Identity.Id).ToList(); var gameResources = new List<GameResource>(); foreach (var game in games) { var links = new GameLinks(game.Id); var gameResource = GameResourceFactory.Create(game, links); gameResources.Add(gameResource); } var gamesResource = new GamesResource(gameResources); //TODO Hier een HAL-Form voor het maken van een nieuwe game aan de resource toevoegen var response = GetResponse(gamesResource); return response; }
public GameResource(SeasonResource thisSeason, TeamResource myTeam, GameLinks links) : base(links) { MyTeam = myTeam; ThisSeason = thisSeason; }
public GameResource(GameLinks links) : this(null, null, links) { }
public HttpResponseMessage Get(string gameId) { RequestHelper.ValidateId(gameId); Game game; bool gameBelongsToUser = TryFindGameForCurrentUser(gameId, out game); if (!gameBelongsToUser) { throw ResponseHelper.Get404NotFound($"Game ID '{gameId}' not found"); } GameResource gameResource = null; if (game.CurrentTeam == null) { //TODO Nu moet je eerst een team kiezen, dus iets met links/forms //gameResource.Links.Add(UriFactory.GetTeamsToChooseFromLink(gameId)); throw ResponseHelper.Get501NotImplemented("You must pick a team now, but this is not implemented yet..."); } else { var seasonService = ServiceFactory.CreateSeasonService(game); var currentSeason = seasonService.GetCurrentSeason(); var thisSeason = GetSeasonResource(currentSeason, game.CurrentTeam); var links = new TeamLinks(game.CurrentTeamId); var myTeam = TeamResourceFactory.Create(game.CurrentTeam, links, true); var matchService = ServiceFactory.CreateMatchService(game); var nextMatchDay = matchService.GetNextMatchDay(currentSeason.Id); string dateForLink = nextMatchDay.ToString("yyyyMMddHH"); var gameLinks = new GameLinks(gameId, currentSeason.Id, dateForLink); gameResource = GameResourceFactory.Create(game, thisSeason, myTeam, gameLinks); } var response = GetResponse(gameResource); return response; }