Skip to content

Commit

Permalink
Fleshed out stat type a bit futher and added SCrosby player career st…
Browse files Browse the repository at this point in the history
…ats.
  • Loading branch information
mmacneil committed Mar 14, 2018
1 parent 346ea09 commit 20a654b
Show file tree
Hide file tree
Showing 6 changed files with 416 additions and 5 deletions.
6 changes: 6 additions & 0 deletions src/backend/NHLStats.Api/Models/SkaterStatisticType.cs
Expand Up @@ -12,8 +12,14 @@ public SkaterStatisticType()
Field(x => x.Id).Description("Id");
Field(x => x.SeasonId).Description("Season id");
Field(x => x.Season.Name).Name("seasonName").Description("Season name");
Field(x => x.League.Abbreviation).Name("league").Description("League");
Field(x => x.Team.Name).Name("team").Description("Team");
// graphql-dotnet can't currently automatically infer int16 so need to resolve manually
Field<IntGraphType>("gamesPlayed", resolve: context => context.Source.GamesPlayed,description: "Games played");
Field<IntGraphType>("goals", resolve: context => context.Source.Goals, description: "Goals");
Field<IntGraphType>("assists", resolve: context => context.Source.Assists, description: "Assists");
Field<IntGraphType>("points", resolve: context => context.Source.Points, description: "Points");
Field<IntGraphType>("plusMinus", resolve: context => context.Source.PlusMinus, description: "+/-");
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/backend/NHLStats.Core/Models/Player.cs
Expand Up @@ -10,6 +10,7 @@ public class Player
public int Id { get; set; }
public string Name { get; set; }
public DateTime BirthDate { get; set; }
public string BirthPlace { get; set; }
public string Height { get; set; }
public int WeightLbs { get; set; }

Expand Down
2 changes: 2 additions & 0 deletions src/backend/NHLStats.Core/Models/SkaterStatistic.cs
Expand Up @@ -7,6 +7,7 @@ public class SkaterStatistic
public int Id { get; set; }
public int SeasonId { get; set; }
public int LeagueId { get; set; }
public int TeamId { get; set; }
public int PlayerId { get; set; }
public ushort GamesPlayed { get; set; }
public ushort Goals { get; set; }
Expand All @@ -17,5 +18,6 @@ public class SkaterStatistic

public virtual Season Season { get; set; }
public virtual League League { get; set; }
public virtual Team Team { get; set; }
}
}
4 changes: 2 additions & 2 deletions src/backend/NHLStats.Data/InMemory/PlayerRepository.cs
Expand Up @@ -10,12 +10,12 @@ namespace NHLStats.Data.InMemory
public class PlayerRepository : IPlayerRepository
{
private readonly List<Player> _players = new List<Player> {
new Player() { Id = 1, Name = "R2-D2" }
new Player() { Id = 1, Name = "Connor McDavid" }
};

public Task<Player> Get(int id)
{
return Task.FromResult(_players.FirstOrDefault(droid => droid.Id == id));
return Task.FromResult(_players.FirstOrDefault(p => p.Id == id));
}
}
}

0 comments on commit 20a654b

Please sign in to comment.