public IEnumerable<MatchForecastResult> TournamentMatches(TournamentViewModel tournament, UserViewModel user) { var matches = Users [user]; return matches.GroupBy (m => m.Match.Tournament, (key, g) => new { Key = key, List = g.ToList () }).First (p => p.Key.Equals(tournament)).List; }
/// <summary> /// Добавялет подчиненный турнир /// </summary> /// <param name="child">Child.</param> public void Add(TournamentViewModel child) { Children.Add (child); child.Parent = this; }
public ActionResult Grouped(int? id, int? pageNum) { TournamentViewModel goldenLeague = new TournamentViewModel { Id = 1, Name = "WG Golden League" }; TournamentViewModel silverLeague = new TournamentViewModel { Id = 2, Name = "WG Silver League" }; TournamentViewModel season1 = new TournamentViewModel { Id = 3, Name = "Первый сезон" }; TournamentViewModel season2 = new TournamentViewModel { Id = 4, Name = "Второй сезон" }; TournamentViewModel cup1 = new TournamentViewModel { Id = 5, Name = "1-й этап" }; TournamentViewModel cup2 = new TournamentViewModel { Id = 6, Name = "2-й этап" }; TournamentViewModel cup3 = new TournamentViewModel { Id = 7, Name = "3-й этап" }; TournamentViewModel cup4 = new TournamentViewModel { Id = 8, Name = "4-й этап" }; goldenLeague.Add(season1); goldenLeague.Add(season2); season2.Add(cup1); season2.Add(cup2); season2.Add(cup3); season2.Add(cup4); var model = new GroupedRatingsViewModel (); model.Tournaments.Add (goldenLeague); model.Tournaments.Add (silverLeague); model.CurrentTournament = id.HasValue ? TournamentViewModel.Flatten(model.Tournaments).First(t => t.Id == id.Value) : cup4; var forecastResults = new List<MatchForecastResult> { new MatchForecastResult { Match = new MatchViewModel { Team1 = "RR-Unity", Team2 = "NA'VI", Tournament = cup4, Results = new List<MatchResultViewModel> { new MatchResultViewModel { Score = "2:3", Success = true } } }, ForecastDate = DateTimeOffset.Now.AddMinutes(-10).AddSeconds(-32), Result = ForecastResult.Complete }, new MatchForecastResult { Match = new MatchViewModel { Team1 = "M1ND", Team2 = "ROX.KIS", Tournament = cup4, Results = new List<MatchResultViewModel> { new MatchResultViewModel { Score = "1:4", Success = true } } }, ForecastDate = DateTimeOffset.Now.AddMinutes(-8).AddSeconds(-32), Result = ForecastResult.Complete }, new MatchForecastResult { Match = new MatchViewModel { Team1 = "NASHORN", Team2 = "KO3AK", Tournament = cup4, Results = new List<MatchResultViewModel> { new MatchResultViewModel { Score = "2:2", Success = true } } }, ForecastDate = DateTimeOffset.Now.AddMinutes(-15).AddSeconds(-32), Result = ForecastResult.Complete }, new MatchForecastResult { Match = new MatchViewModel { Team1 = "ZEOS", Team2 = "NOD", Tournament = cup4, Results = new List<MatchResultViewModel> { new MatchResultViewModel { Score = "4:1", Success = true } } }, ForecastDate = DateTimeOffset.Now.AddMinutes(-3).AddSeconds(-32), Result = ForecastResult.OnlyWinner }, new MatchForecastResult { Match = new MatchViewModel { Team1 = "RR-Unity", Team2 = "NA'VI", Tournament = cup3, Results = new List<MatchResultViewModel> { new MatchResultViewModel { Score = "2:3", Success = true } } }, ForecastDate = DateTimeOffset.Now.AddMinutes(-20).AddSeconds(-32), Result = ForecastResult.Complete }, new MatchForecastResult { Match = new MatchViewModel { Team1 = "M1ND", Team2 = "ROX.KIS", Tournament = cup3, Results = new List<MatchResultViewModel> { new MatchResultViewModel { Score = "1:4", Success = true } } }, ForecastDate = DateTimeOffset.Now.AddMinutes(-15).AddSeconds(-32), Result = ForecastResult.Complete }, new MatchForecastResult { Match = new MatchViewModel { Team1 = "NASHORN", Team2 = "KO3AK", Tournament = cup3, Results = new List<MatchResultViewModel> { new MatchResultViewModel { Score = "2:2", Success = true } } }, ForecastDate = DateTimeOffset.Now.AddMinutes(-10).AddSeconds(-32), Result = ForecastResult.Complete }, new MatchForecastResult { Match = new MatchViewModel { Team1 = "ZEOS", Team2 = "NOD", Tournament = cup3, Results = new List<MatchResultViewModel> { new MatchResultViewModel { Score = "4:1", Success = true } } }, ForecastDate = DateTimeOffset.Now.AddMinutes(-5).AddSeconds(-32), Result = ForecastResult.Error }, }; model.Users.Add ( new UserViewModel { DisplayName = "Dimon", ForecastsCount = 127, NewPosition = 1, OldPosition = 9, SuccessPercent = 67.10M }, forecastResults ); model.Users.Add ( new UserViewModel { DisplayName = "Vasya", ForecastsCount = 1327, NewPosition = 2, OldPosition = 1, SuccessPercent = 65.00M }, forecastResults ); model.Users.Add ( new UserViewModel { DisplayName = "Petrovich", ForecastsCount = 12, NewPosition = 3, OldPosition = 3, SuccessPercent = 45.62M }, forecastResults ); model.Users.Add ( new UserViewModel { DisplayName = "Gorynuch", ForecastsCount = 62, NewPosition = 4, OldPosition = 5, SuccessPercent = 34.62M }, forecastResults ); model.PageCount = 10; model.PageNumber = pageNum.HasValue ? pageNum.Value : 1; return View(model); }
public ActionResult Index(int? pageNum) { TournamentViewModel goldenLeague = new TournamentViewModel { Id = 1, Name = "WG Golden League" }; TournamentViewModel silverLeague = new TournamentViewModel { Id = 2, Name = "WG Silver League" }; TournamentViewModel season1 = new TournamentViewModel { Id = 3, Name = "Первый сезон" }; TournamentViewModel season2 = new TournamentViewModel { Id = 4, Name = "Второй сезон" }; TournamentViewModel cup1 = new TournamentViewModel { Id = 5, Name = "1-й этап" }; TournamentViewModel cup2 = new TournamentViewModel { Id = 5, Name = "2-й этап" }; TournamentViewModel cup3 = new TournamentViewModel { Id = 5, Name = "3-й этап" }; TournamentViewModel cup4 = new TournamentViewModel { Id = 5, Name = "4-й этап" }; goldenLeague.Add(season1); goldenLeague.Add(season2); season2.Add(cup1); season2.Add(cup2); season2.Add(cup3); season2.Add(cup4); EventsViewModel model = new EventsViewModel (); model.CurrentTournament = cup4; model.Tournaments.Add (goldenLeague); model.Tournaments.Add (silverLeague); model.PageNumber = pageNum.HasValue ? pageNum.Value : 1; model.PageCount = 10; model.Matches = new List<MatchViewModel> { new MatchViewModel { Team1 = "RR-Unity", Team2 = "NA'VI", MapName = "Монастырь", Description = "<p><a href=\"#\">RR-Unity</a> нужна победа как воздух, чтобы пройти в финальную часть сезона. И ребята настроены очень решительно. Однако статистика последних встреч команд не в пользу RR-Unity. Они стабильно уступали команде Делюкса на протяжении последнего полугода.</p><p><a href=\"#\">NA'VI</a> является сильнейшей командой РУ-кластера, что они подтвердили в первом сезоне Golden лиги. Они прекрасно осведомлены о возможностях соперника и отлично знакомы с его тактиками. Однако, это может сыграть злую шутку с командой и, расслабившись, они могу уступить пару раундов, а то и встречу.</p>", Tags = new List<string> { "RR-Unity", "NA'VI", "матч тура" }, DateBegin = DateTimeOffset.Now.Date.AddHours(21), Image = "~/Content/images/fight.png", Tournament = cup4, Results = new List<MatchResultViewModel> { new MatchResultViewModel { Score = "5 : 0", Percent = 1, Votes = 1 }, new MatchResultViewModel { Score = "4 : 1", Percent = 4, Votes = 4 }, new MatchResultViewModel { Score = "3 : 2", Percent = 5, Votes = 5 }, new MatchResultViewModel { Score = "2 : 3", Percent = 5, Votes = 5 }, new MatchResultViewModel { Score = "1 : 4", Percent = 20, Votes = 20 }, new MatchResultViewModel { Score = "0 : 5", Percent = 65, Votes = 65 }, } }, new MatchViewModel { Team1 = "M1ND", Team2 = "ROX.KIS", MapName = "Монастырь", Description = "", Tags = new List<string> { "M1ND", "ROX.KIS", "баттл" }, Image = "~/Content/images/fight2.png", Tournament = cup4, DateBegin = DateTimeOffset.Now.Date.AddHours(23).AddMinutes(30), Results = new List<MatchResultViewModel> { new MatchResultViewModel { Score = "5 : 0", Percent = 1, Votes = 1 }, new MatchResultViewModel { Score = "4 : 1", Percent = 4, Votes = 4 }, new MatchResultViewModel { Score = "3 : 2", Percent = 15, Votes = 15 }, new MatchResultViewModel { Score = "2 : 3", Percent = 15, Votes = 15 }, new MatchResultViewModel { Score = "1 : 4", Percent = 10, Votes = 10 }, new MatchResultViewModel { Score = "0 : 5", Percent = 55, Votes = 55 }, } }, new MatchViewModel { Team1 = "NASHORN", Team2 = "КОЗАК", MapName = "Энск", Description = "", Tags = new List<string> { "golden league", "второй сезон", "2-й этап" }, Image = "~/Content/images/fight3.png", Tournament = cup4, DateBegin = DateTimeOffset.Now.Date.AddHours(-12).AddMinutes(-30), Results = new List<MatchResultViewModel> { new MatchResultViewModel { Score = "5 : 0", Percent = 1, Votes = 1 }, new MatchResultViewModel { Score = "4 : 1", Percent = 4, Votes = 4 }, new MatchResultViewModel { Score = "3 : 2", Percent = 15, Votes = 15 }, new MatchResultViewModel { Score = "2 : 3", Percent = 35, Votes = 35, Success = true }, new MatchResultViewModel { Score = "1 : 4", Percent = 10, Votes = 10 }, new MatchResultViewModel { Score = "0 : 5", Percent = 35, Votes = 35 }, } } }; return View("Index", model); }