コード例 #1
0
        private static void FillSeasonDataIntoStringTupleLists(StringTupleLists stringTupleLists, int seasonYearOrNumber)
        {
            SeasonCalculations seasonCalculations = new SeasonCalculations();

            stringTupleLists.AddStringPair(
                "Season_Number",
                seasonCalculations.GetNumberFromYearOrNumber(seasonYearOrNumber).ToString());
            stringTupleLists.AddStringPair(
                "Season_Year",
                seasonCalculations.GetYearFromYearOrNumber(seasonYearOrNumber).ToString());
        }
コード例 #2
0
        // GET: Calculation
        public ActionResult Index(int id = 1)
        {
            SeasonCalculations calc = new SeasonCalculations((Season)id, _teamsRepository, _activityRepository,
                                                             _rankingRepository, _positionsRepository, _estimatedRankingRepository);
            Activity isActive;

            EstimatedRankings[] points;
            calc.GetRanking(out points, out isActive);
            List <CalculationsViewModel> viewModel      = new List <CalculationsViewModel>();
            EstimatedRankings            currentRanking = ConvertHelper.ConvertPositionsToRanking(calc.GetPosition((Season)id));
            Positions         previousRanking           = calc.GetPosition((Season)id - 1);
            EstimatedRankings prevRanking = null;

            if (previousRanking != null)
            {
                prevRanking = ConvertHelper.ConvertPositionsToRanking(previousRanking);
            }
            foreach (Teams team in allTeams)
            {
                PropertyInfo propInfo = isActive.GetType().GetProperty(team.Name.Replace(' ', '_').Replace('.', '_'));
                if (Convert.ToBoolean(propInfo.GetValue(isActive)))
                {
                    propInfo = points[0].GetType().GetProperty(team.Name.Replace(' ', '_').Replace('.', '_'));
                    int   prevRank = prevRanking == null ? 0 : Convert.ToInt32(propInfo.GetValue(prevRanking));
                    int[] res      = new int[7];
                    viewModel.Add(new CalculationsViewModel(team, new int[] { Convert.ToInt32(propInfo.GetValue(points[0])), Convert.ToInt32(propInfo.GetValue(points[1])),
                                                                              Convert.ToInt32(propInfo.GetValue(points[2])), Convert.ToInt32(propInfo.GetValue(points[3])), Convert.ToInt32(propInfo.GetValue(points[4])),
                                                                              Convert.ToInt32(propInfo.GetValue(points[5])), Convert.ToInt32(propInfo.GetValue(points[6])) }, Convert.ToInt32(propInfo.GetValue(currentRanking)), prevRank));
                }
            }
            viewModel = viewModel.OrderByDescending(x => x.Points[6]).ToList();
            List <Teams> drawTeams  = new List <Teams>();
            List <int[]> drawPoints = new List <int[]>();

            foreach (CalculationsViewModel vm in viewModel.Take(5))
            {
                drawTeams.Add(vm.Team);
                drawPoints.Add(vm.Points);
            }
            DrawChart drawChart = new DrawChart();
            string    path      = drawChart.GenerateChart(drawTeams, drawPoints, (Season)id);

            ViewBag.Season            = (Season)id;
            ViewBag.SeasonDisplayName = Helpers.Helper.GetSeasonDisplayName((Season)id);
            ViewBag.Path = path;
            return(View(viewModel));
        }