public ActionResult Index(int?Spieltag)
        {
            var allGroups = _matchDataRepository.GetAllGroups();

            int currentSpieltag = (Spieltag.HasValue == true) ? Spieltag.Value : SportsdataConfigInfo.Current.StartSpieltag;

            // build dropdown list data
            {
                var count             = SportsdataConfigInfo.Current.EndSpieltag - SportsdataConfigInfo.Current.StartSpieltag + 1;
                var ddlSpieltageRange = (from e in allGroups
                                         where e.Id <= SportsdataConfigInfo.Current.EndSpieltag &&
                                         e.Id >= SportsdataConfigInfo.Current.StartSpieltag
                                         select new SelectListItem()
                {
                    Value = e.Id.ToString(),
                    Text = e.Text,
                    Selected = (e.Id == currentSpieltag)
                });

                ViewBag.Spieltag = ddlSpieltageRange;

                var quotes = _quoteRepository.GetOdds();
            }

            return(View());
        }
Beispiel #2
0
        public ActionResult Index(int?Spieltag)
        {
            log.Debug("Index begin");

            var allGroups = _matchDataRepository.GetAllGroups();

            int currentSpieltag = Spieltag ?? SportsdataConfigInfo.Current.CurrentSpieltag;

            // build dropdown list data
            {
                var count             = SportsdataConfigInfo.Current.EndSpieltag - SportsdataConfigInfo.Current.StartSpieltag + 1;
                var ddlSpieltageRange = (from e in allGroups
                                         where e.Id <= SportsdataConfigInfo.Current.EndSpieltag &&
                                         e.Id >= SportsdataConfigInfo.Current.StartSpieltag
                                         select new SelectListItem()
                {
                    Value = e.Id.ToString(),
                    Text = e.Text,
                    Selected = (e.Id == currentSpieltag)
                });

                ViewBag.Spieltag = ddlSpieltageRange;
            }

            var model = new SpieltagModel();

            model.GroupId   = currentSpieltag;
            model.GroupName = allGroups.Find(g => g.Id == currentSpieltag).Text;

            var oddsList = _quoteRepository.GetOdds(currentSpieltag);

            var matches = _matchDataRepository.GetMatchesByGroup(currentSpieltag);

            matches = (from m in matches
                       orderby m.KickoffTime
                       select m).ToList();

            foreach (var m in matches)
            {
                var modelAllInfo = new MatchInfoModel()
                {
                    MatchId       = m.MatchId,
                    GroupId       = m.GroupId,
                    MatchNr       = m.MatchNr,
                    AwayTeam      = m.AwayTeam,
                    AwayTeamIcon  = m.AwayTeamIcon,
                    AwayTeamScore = m.AwayTeamScore,
                    HomeTeam      = m.HomeTeam,
                    HomeTeamIcon  = m.HomeTeamIcon,
                    HomeTeamScore = m.HomeTeamScore,
                    IsFinished    = m.IsFinished,
                    KickoffTime   = m.KickoffTime
                };

                // mixin odds quotes into match data
                MixinOddsQuotes(oddsList, modelAllInfo);

                using (var ctxt = new TippSpielContext())
                {
                    var myTippObject = (from t in ctxt.TippMatchList
                                        where t.MatchId == modelAllInfo.MatchId &&
                                        t.User == User.Identity.Name
                                        select t)
                                       .FirstOrDefault();

                    if (myTippObject != null)
                    {
                        modelAllInfo.MyOdds   = myTippObject.MyOdds;
                        modelAllInfo.MyTip    = myTippObject.MyTip;
                        modelAllInfo.IsJoker  = myTippObject.IsJoker;
                        modelAllInfo.MyAmount = myTippObject.MyAmount;
                    }
                }


                model.Matchdata.Add(modelAllInfo);
            }

            model.MaxJokers     = TippspielConfigInfo.Current.MaxJokerTips;
            model.NumJokersUsed = model.Matchdata.Count(m => m.IsJoker);

            {
                log.DebugFormat("Tipp data stats: remote hits={0}, cache hits={1}", MatchDBStats.GetRemoteHits(), MatchDBStats.GetCacheHits());
            }

            log.Debug("Index end");

            return(View(model));
        }