Beispiel #1
0
        //
        // GET: /Match/
        public ActionResult Index()
        {
            var repository = GetRepository<Match>();
            var repBoxer = GetRepository<Boxer>();
            var matches = repository.All();

            //Build the matches list by Months!!!
            var summarysDic = new Dictionary<string, IEnumerable<MatchSummary>>();
            for (int i = 1; i <= 12; i++)
            {
                var MatchesOfMonth = matches.GetNextMatchesWithAProspect().Where(x => x.MatchDate.Value.Year == DateTime.Now.Year &&
                                    x.MatchDate.Value.Month == i);
                if (MatchesOfMonth.Count() > 0)
                {
                    var firstMatchDate = MatchesOfMonth.First().MatchDate.Value;
                    if (firstMatchDate.Year != DateTime.Now.Year)
                    {
                        summarysDic.Add(firstMatchDate.ToString("MMMM yyyy"), MatchesOfMonth.OrderBy(x => x.MatchDate).Select(x => new MatchSummary(x)).ToArray());
                    }
                    else
                    {
                        summarysDic.Add(firstMatchDate.ToString("MMMM"), MatchesOfMonth.OrderBy(x => x.MatchDate).Select(x => new MatchSummary(x)).ToArray());
                    }
                }
            }

            var model = new MatchViewModel()
            {

                MatchResults = matches.Where(x => x.HasResult())
                                                .OrderByDescending(x => x.MatchDate)
                                                .Take(10).Select(x => new ResultSummary(x))
                                                .ToArray(),

                NextMatches = matches.Where(x => x.MatchDate != null && x.MatchDate > DateTime.Now)
                                                    .OrderBy(x => x.MatchDate)//.Select(x => new MatchSummary(x))
                                                    .Take(10),

                RedBox_Rankings = repBoxer.Query().TopRankings(10),

                MatchMonths = summarysDic
            };
            ViewData["Title"] = "Upcoming Matches";
            ViewData["ViewBy"] = "newest";
            return View(model);
        }
Beispiel #2
0
        public ActionResult Result()
        {
            var repository = GetRepository<Match>();
            var model = new MatchViewModel()
            {
                MatchesWithoutAResult = repository.Query().GetMatchesThatNeedResults().Select(x => new MatchSummary(x)).ToArray()
            };

            return View(model);
        }