Пример #1
0
        public ActionResult SaveSeries(NPSeries series)
        {
            _seriesService.Save(series);

            return RedirectToAction("Series");
        }
Пример #2
0
        public SeriesStandingsViewModel(NPSeries series, NPPick pick)
        {
            string title = string.Format("{0} {1}", series.Division,series.Round.Name);
            string subTitle = "";
            UserPick = pick;
            RoundNumber = series.Round.Id;
            RoundName = series.Round.Name;
            switch (RoundNumber)
            {
                case 1: RoundBGColor = "#146188"; RoundFColor = "#FFFFFF"; break;
                case 2: RoundBGColor = "#062831"; RoundFColor = "#FFFFFF"; break;
                case 3: RoundBGColor = "#CCCCCC"; RoundFColor = "#000000"; break;
                default: RoundBGColor = "#EAB53F"; RoundFColor = "#000000"; break;
            }
            if (RoundNumber >= 5)
            {
                return;
            }
            if (series.SeriesWon.Value)
            {
                if (series.HigherSeedWinTotal.Value > series.LowerSeedWinTotal.Value)
                {
                    subTitle = string.Format("{0} defeat {1} in {2} ", series.HigherSeed.Name, series.LowerSeed.Name, series.HigherSeedWinTotal.Value + series.LowerSeedWinTotal.Value);
                } else {
                    subTitle = string.Format("{0} defeat {1} in {2}", series.LowerSeed.Name, series.HigherSeed.Name, series.LowerSeedWinTotal.Value + series.HigherSeedWinTotal.Value);
                }
            }
            else
            {
                if (series.HigherSeedWinTotal == series.LowerSeedWinTotal)
                {
                    if ((series.HigherSeedWinTotal.HasValue == false) || (series.LowerSeedWinTotal.HasValue == false)) {
                        subTitle = string.Format("{0} vs. {1}", series.HigherSeed.RankName, series.LowerSeed.RankName);
                    } else {
                        subTitle = string.Format("{0} tied with {1} {2} - {3}", series.HigherSeed.Name, series.LowerSeed.Name, series.HigherSeedWinTotal.Value, series.LowerSeedWinTotal.Value);
                    }
                }
                else
                {
                    if (series.HigherSeedWinTotal > series.LowerSeedWinTotal) {
                        subTitle = string.Format("{0} lead {1} {2} - {3}", series.HigherSeed.Name, series.LowerSeed.Name, series.HigherSeedWinTotal, series.LowerSeedWinTotal);
                    } else {
                        subTitle = string.Format("{0} lead {1} {2} - {3}", series.LowerSeed.Name, series.HigherSeed.Name, series.LowerSeedWinTotal, series.HigherSeedWinTotal);
                    }
                }

            }
            SeriesCompleted = series.SeriesWon.HasValue ? series.SeriesWon.Value : false;
            SeriesLabel = string.Format("{0} vs. {1}", series.HigherSeed.Name, series.LowerSeed.Name);
            SeriesTitle = title;
            SeriesId = series.Id;
            Title = subTitle;
            HigherSeedName = series.HigherSeed.Name;
            LowerSeedName = series.LowerSeed.Name;
            SeriesGames = new List<Game>();
            int gameCount = 0;
            foreach (var game in series.Games)
            {
                string higherSeedCourt = "HOME";
                string lowerSeedCourt = "AWAY";
                int[] advantage = new int[3]{3,4,6};
                if (advantage.Contains(Convert.ToInt32(game.Number)))
                {
                    higherSeedCourt = "AWAY";
                    lowerSeedCourt = "HOME";
                }
                else
                {
                    higherSeedCourt = "HOME";
                    lowerSeedCourt = "AWAY";
                }
                SeriesGames.Add(new Game()
                    {
                          HigherSeedCourt = higherSeedCourt
                        , HigherSeedScore  = Convert.ToInt16(game.HigherSeedScore)
                        , LowerSeedCourt = lowerSeedCourt
                        , LowerSeedScore =Convert.ToUInt16( game.LowerSeedScore)
                        , HigherSeedTeam = (game.HigherSeedScore > game.LowerSeedScore) ? HigherSeedName.ToUpper() : HigherSeedName
                        , LowerSeedTeam =  (game.LowerSeedScore > game.HigherSeedScore) ? LowerSeedName.ToUpper()  : LowerSeedName
                        , GameDate = game.DateTime == null ? string.Empty : game.DateTime.Value.ToString("MMMM d")
                        , GameTime = game.DateTime == null ? string.Empty : game.DateTime.Value.ToString("h:mm CDT")
                    });

                gameCount++;
                if(series.SeriesWon.Value && gameCount >= (series.HigherSeedWinTotal + series.LowerSeedWinTotal))
                {
                    break;
                }
            }
        }