コード例 #1
0
 public SkillLevelCalculationViewModel(User player, IRepository repository)
 {
     var results = new List<SkillLevelMatchResultViewModel>();
       var sl = player.SkillLevels.Where(s => s.GameType == GameType.EightBall).SingleOrDefault();
       if (null != sl) {
     EightBallSkillLevel = sl.Value;
     var matchResults = player.GetMatchResultsUsedInSkillLevelCalculation(GameType.EightBall, repository);
     HasSkillLevel = true;
     var culledMatchResults = player.CullTopMatchResults(matchResults);
     foreach (var result in matchResults) {
       var resultvm = new SkillLevelMatchResultViewModel(result, player);
       results.Add(resultvm);
       if (culledMatchResults.Contains(result)) {
     resultvm.Included = true;
     TotalCulledInnings += resultvm.Innings;
     TotalCulledDefensiveShots += resultvm.DefensiveShots;
     TotalCulledNetInnings += resultvm.NetInnings;
     TotalCulledWins += resultvm.Wins;
       }
       TotalInnings += resultvm.Innings;
       TotalDefensiveShots += resultvm.DefensiveShots;
       TotalNetInnings += resultvm.NetInnings;
       TotalWins += resultvm.Wins;
     }
     TotalIG = (double)TotalNetInnings / (double)TotalWins;
     CulledIG = (double)TotalCulledNetInnings / (double)TotalCulledWins;
       }
       SkillLevelMatchResults = results.OrderByDescending(r => r.Date);
 }