Example #1
0
        public new ActionResult Profile(int boardId, int competitorId)
        {
            var board      = _repository.GetBoardById(boardId);
            var competitor = _repository.GetCompetitorById(competitorId);

            if (competitor == null)
            {
                return(View("CompetitorNotFound", board));
            }

            var matches = _repository.GetResolvedMatchesByBoardId(boardId)
                          .InvolvesCompetitor(competitor)
                          .OrderByDescending(m => m.Created);

            var stats = _matchService.CalculateCompetitorStats(competitor, matches.ToList());

            return
                (View(new ProfileViewModel
            {
                Board = board,
                Competitor = competitor,
                Matches = matches.Take(300),
                Stats = stats
            }));
        }