Beispiel #1
0
        public HomeModel(DateTime date, HttpRequestBase request)
            : base(request)
        {
            this.Date = date;
            var today = DateTime.UtcNow.AddHours(-8);

            var gameSummaryCreator = new GameSummaryCreator();
            GameCollection = gameSummaryCreator.GetSummaryCollection(this.Date);

            if (GameCollection != null && GameCollection.GameSummaries == null && this.Date.Day == today.Day)
            {
                this.Date = date.AddDays(-1);
                GameCollection = gameSummaryCreator.GetSummaryCollection(this.Date);
            }
        }
Beispiel #2
0
        public GameModel(DateTime date, int gamePk, HttpRequestBase request)
            : base(request)
        {
            this.Date = date;

            var gameSummaryCreator = new GameSummaryCreator();
            var gameCollection = gameSummaryCreator.GetSummaryCollection(date);
            this.GameSummary = gameCollection.GameSummaries.FirstOrDefault(game => game.GamePk == gamePk);
            if (this.GameSummary == default(GameSummary)) return;

            var gameDetailCreator = new GameDetailCreator(this.GameSummary.GameDataDirectory);
            HighlightsCollection = gameDetailCreator.GetHighlights();
            if (HighlightsCollection == default(HighlightsCollection)) return;

            foreach (var highlight in HighlightsCollection.Highlights.Where(a => a != null && a.Urls != null))
            {
                for (var i = 0; i < highlight.Urls.Length; i++)
                {
                    var url = highlight.Urls[i];

                    if (url.Contains("1200K"))
                    {
                        var urls = new List<string>(highlight.Urls);

                        var url2500 = url.Replace("1200K", "2500K");
                        var url1800 = url.Replace("1200K", "1800K");

                        if (RemoteFileExists(url1800))
                        {
                            urls.Add(url1800);
                        }

                        if (RemoteFileExists(url2500))
                        {
                            urls.Add(url2500);
                        }

                        highlight.Urls = urls.ToArray();
                    }
                }
            }
        }