Ejemplo n.º 1
0
        public async Task GetAndSeparateData(string EventID)
        {
            AuthorizedTeams = await _context.Team.AsNoTracking().Where(t => t.EventID == EventID).ToListAsync();

            AuthorizedOfficialMatches     = _context.OfficialMatch.AsNoTracking().Where(m => m.EventID == EventID).OrderBy(m => m.MatchNumber);
            QualificationsOfficialMatches = await AuthorizedOfficialMatches.Where(m => m.MatchType == MatchType.Qualification).ToListAsync();

            SemifinalsOfficialMatches = await AuthorizedOfficialMatches.Where(m => m.MatchType == MatchType.Semifinal).ToListAsync();;
            FinalsOfficialMatches     = await AuthorizedOfficialMatches.Where(m => m.MatchType == MatchType.Final).ToListAsync();

            PracticeOfficialMatches = await AuthorizedOfficialMatches.Where(m => m.MatchType == MatchType.Practice).ToListAsync();;
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> OnGetAsync(string EventID)
        {
            if (EventID == null)
            {
                return(NotFound());
            }
            if (!AuthorizationCheck.Event(_context, EventID, User.Identity.Name))
            {
                return(Forbid());
            }

            eventID = EventID;
            await GetAndSeparateData(EventID);

            int BestRedScore  = AuthorizedOfficialMatches.Max(m => m.RedScore).GetValueOrDefault();
            int BestBlueScore = AuthorizedOfficialMatches.Max(m => m.BlueScore).GetValueOrDefault();

            BestScore = System.Math.Max(BestRedScore, BestBlueScore);
            TeamCount = await _context.Team.AsNoTracking().Where(t => t.EventID == EventID).CountAsync();

            try
            {
                int ScoresSum = 0;
                foreach (var Match in AuthorizedOfficialMatches)
                {
                    ScoresSum += Match.RedScore.GetValueOrDefault();
                    ScoresSum += Match.BlueScore.GetValueOrDefault();
                }
                AverageScore = ScoresSum / (AuthorizedOfficialMatches.Count() * 2);
                AverageScore = System.Math.Round(AverageScore, 2);

                MatchesPerTeam = AuthorizedOfficialMatches.Count() * 4 / AuthorizedTeams.Count;
                MatchesPerTeam = System.Math.Round(MatchesPerTeam, 2);
            }
            catch
            {
                AverageScore   = 0;
                MatchesPerTeam = 0;
            }
            return(Page());
        }