Ejemplo n.º 1
0
        public Resource Map(Team team, params string[] properties)
        {
            var resource = new Resource(new Link(_uriHelper.GetTeamUri(team.GameId, team.Id)));

            if (properties.Contains(TeamName))
            {
                resource.AddProperty(TeamName, team.Name);
            }

            if (properties.Contains(Rating))
            {
                resource.AddProperty(Rating, team.Rating);
            }

            if (properties.Contains(RatingGoalkeeper))
            {
                resource.AddProperty(RatingGoalkeeper, team.RatingGoalkeeper);
            }

            if (properties.Contains(RatingDefence))
            {
                resource.AddProperty(RatingDefence, team.RatingDefence);
            }

            if (properties.Contains(RatingMidfield))
            {
                resource.AddProperty(RatingMidfield, team.RatingMidfield);
            }

            if (properties.Contains(RatingAttack))
            {
                resource.AddProperty(RatingAttack, team.RatingAttack);
            }

            if (properties.Contains(RatingPercentage))
            {
                var ratingPercentage = (team.Rating / 20) * 100;
                resource.AddProperty(RatingPercentage, ratingPercentage);
            }

            if (properties.Contains(LeagueName))
            {
                resource.AddProperty(LeagueName, team.CurrentLeagueCompetition.Name);
            }

            if (properties.Contains(CurrentLeaguePosition))
            {
                resource.AddProperty(CurrentLeaguePosition, team.CurrentLeaguePosition);
            }

            return(resource);
        }
Ejemplo n.º 2
0
        public Resource Create(string selfUri, GameInfo gameInfo)
        {
            // Create the HAL document with the given self URI.
            var halDocument = new Resource(new Link(selfUri));

            // Add the curies link.
            var curiesLink = new Link(_uriHelper.GetRelationsUri())
            {
                Templated = true
            };

            halDocument.AddLink("curies", curiesLink);

            // The manager's current team.
            if (gameInfo != null)
            {
                var currentTeamLink = new Link(_uriHelper.GetTeamUri(gameInfo.Id, gameInfo.CurrentTeamId));
                halDocument.AddLink("rel:managers-team", currentTeamLink);
            }

            //         var mainLinks = new List<Link>();

            // Add the home link to the main links.
            //         var homeLink = new Link(_uriHelper.GetHomeUri()) { Title = "Home" };
            //         mainLinks.Add(homeLink);

            //         if (_loggedIn)
            //         {
            // Add the Games link.
            //            var gamesLink = new Link(_uriHelper.GetGamesUri()) { Title = "Games" };
            //            mainLinks.Add(gamesLink);

            // Add game specific links.
            //            if (gameInfo != null)
            //            {
            //               CreateGameMenu(gameInfo, halDocument);
            //            }
            //         }

            //         halDocument.AddLink("main", mainLinks);

            return(halDocument);
        }