public List <SpieltagModel> GetSpieltagMock()
        {
            List <SpieltagModel> spieltagListe = new List <SpieltagModel>();

            SpieltagModel elfterSpieltag = new SpieltagModel();

            elfterSpieltag.Begegnung   = "Freiburg - Eintracht Frankfurt 1:0 (0:0)";
            elfterSpieltag.Information = "Der SC Freiburg geht als Tabellenvierter in die Länderspielpause: Die Breisgauer fuhren am Sonntagabend einen knappen 1:0-Erfolg gegen Eintracht Frankfurt ein. Dabei profitierten die Hausherren auch von einer 45-minütigen Überzahlsituation. Denkwürdig sollte letztlich aber besonders die Nachspielzeit werden.";

            spieltagListe.Add(elfterSpieltag);
            return(spieltagListe);
        }
Example #2
0
        //Die Methode CreateSpieltagDTO() erstellt ein neues Objekt in unserer Liste "SpieltagModel" und returned die Liste "spieltags"
        public List <SpieltagModel> CreateSpieltagDTO(BundesligaDeserializing bundesligaCollection)
        {
            List <SpieltagModel> spieltags = new List <SpieltagModel>();

            foreach (var item in bundesligaCollection.Channel.Items)
            {
                SpieltagModel neuesSpiel = new SpieltagModel();
                neuesSpiel.Begegnung   = item.Title;
                neuesSpiel.Information = item.Description;

                spieltags.Add(neuesSpiel);
            }
            return(spieltags);
        }
Example #3
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));
        }
Example #4
0
        public ActionResult Index(int?Spieltag)
        {
            var spieltagInfo = OpenDBHelper.GetSpieltagInfo(_matchDataRepository);

            int currentSpieltag = (Spieltag.HasValue == true) ?
                                  Spieltag.Value :
                                  spieltagInfo.TippSpieltag;

            // build dropdown list data
            {
                var count             = SportsdataConfigInfo.Current.EndSpieltag - SportsdataConfigInfo.Current.StartSpieltag + 1;
                var ddlSpieltageRange = (from e in Enumerable.Range(SportsdataConfigInfo.Current.StartSpieltag, count)
                                         select new SelectListItem()
                {
                    Value = e.ToString(), Text = "Spieltag " + e.ToString(), Selected = (e == currentSpieltag)
                });

                ViewBag.Spieltag = ddlSpieltageRange;
            }

            var model = new SpieltagModel();

            model.Spieltag = currentSpieltag;

            if ((currentSpieltag == 34 || currentSpieltag == 0) && spieltagInfo.IsCompleted)
            {
                model.IsTippSpielFinished = true;
                return(View(model));
            }

            List <OddsInfoModel> oddsList = null;

            try
            {
                oddsList = WettfreundeScraper.Scrap(currentSpieltag);
            }
            catch (Exception ex)
            {
                _log.Error("Error while scrab odds: " + ex.Message);
                string fixFilename = String.Format("Odds_{0}_{1}_{2}", SportsdataConfigInfo.Current.LeagueShortcut, SportsdataConfigInfo.Current.LeagueSaison, currentSpieltag);
                _log.Info("Try fix: " + fixFilename);

                ResourceManager rm         = new ResourceManager(typeof(Resources));
                var             fixContent = rm.GetObject(fixFilename) as string;

                var oddScraper = new WettfreundeOddsBuLiScraper();

                oddsList = oddScraper.GetOdds(fixContent, currentSpieltag.ToString());
            }

            var matches = _matchDataRepository.GetMatchesByGroup(currentSpieltag);

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

                model.IsSpieltagFinished = (model.IsSpieltagFinished && modelAllInfo.IsFinished);

                // 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.MyAmount = myTippObject.MyAmount;
                    }
                }


                model.Matchdata.Add(modelAllInfo);
            }

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

            return(View(model));
        }