Beispiel #1
0
        public IActionResult TheMostEffectiveDay()
        {
            InitializeLeagues();

            var stat = new Dictionary <string, int>();

            foreach (var league in leagues)
            {
                foreach (var match in league.Matches)
                {
                    var day = new EffectiveDay();

                    if (stat.ContainsKey(match.Date))
                    {
                        stat[match.Date] += match.Score.Ft[0] + match.Score.Ft[1];
                    }
                    else
                    {
                        stat.Add(match.Date, match.Score.Ft[0] + match.Score.Ft[1]);
                    }
                }

                foreach (var item in stat)
                {
                    var day = new EffectiveDay();
                    day.Date  = item.Key;
                    day.Goals = item.Value;
                    days.Add(day);
                }
            }

            int theMostGoalsInLeaguesInADay = 0;

            foreach (var league in leagues)
            {
                theMostGoalsInLeaguesInADay = days.Max(t => t.Goals);
            }

            EffectiveDay theMostEffectiveDay = new EffectiveDay();

            theMostEffectiveDay.Date  = days.Where(x => x.Goals == theMostGoalsInLeaguesInADay).First().Date;
            theMostEffectiveDay.Goals = theMostGoalsInLeaguesInADay;

            return(View(theMostEffectiveDay));
        }
Beispiel #2
0
        // GET: EffectiveDay
        public ActionResult EffectiveDay()
        {
            var legues = new List <Legue>();

            legues.Add(legue1);
            legues.Add(legue2);
            legues.Add(legue3);

            Dictionary <string, int> resultDay = new Dictionary <string, int>();

            foreach (var legue in legues)
            {
                foreach (var match in legue.Matches)
                {
                    if (resultDay.ContainsKey(match.Date))
                    {
                        resultDay[match.Date] += match.Score.Ft[0] + match.Score.Ft[1];
                    }
                    else
                    {
                        resultDay.Add(match.Date, match.Score.Ft[0] + match.Score.Ft[1]);
                    }
                }
            }

            int maxPoints = 0;

            foreach (KeyValuePair <string, int> entry in resultDay)
            {
                if (entry.Value > maxPoints)
                {
                    maxPoints = entry.Value;
                }
            }

            EffectiveDay result = new EffectiveDay();

            result.Date   = resultDay.FirstOrDefault(x => x.Value == maxPoints).Key;
            result.Points = resultDay[result.Date];

            return(View(result));
        }