コード例 #1
0
        public ActionResult AddPlayer(GamesViewModel viewModel)
        {
            if (viewModel.NewPlayer != null)
            {
                AddPlayer(viewModel.NewPlayer);
            }

            return RedirectToAction("Resume", new { @season = viewModel.Season, @gameType = viewModel.GameType });
        }
コード例 #2
0
        public ActionResult Teste(GamesViewModel viewModel)
        {
            //if (viewModel.NewPlayer != null)
            //{
            //    AddPlayer(viewModel.NewPlayer);
            //}

            //string formatTeamA = "1=GK_{0}%201_1_388_174&2=ML_{1}%207_7_189_64&3=DM_{2}%2010_10_267_180&4=FC_{3}%209_9_75_173&5=MR_{4}%2020_20_175_296&6=MLA___204_64&7=MCL___222_138&8=MCR___222_211&9=MRA___204_284&10=FCL___98_138&11=FCR___98_211&c2=ffffff&c3=ffffff&output=embed";

            //viewModel.TeamA = string.Format(principalURL_teamA + formatTeamA,
            //    classificationPlayers[0].PlayerName,
            //    classificationPlayers[3].PlayerName,
            //    classificationPlayers[5].PlayerName,
            //    classificationPlayers[6].PlayerName,
            //    classificationPlayers[9].PlayerName);

            //viewModel.PlayersTeamA.Add(classificationPlayers[0].PlayerName);
            //viewModel.PlayersTeamA.Add(classificationPlayers[3].PlayerName);
            //viewModel.PlayersTeamA.Add(classificationPlayers[5].PlayerName);
            //viewModel.PlayersTeamA.Add(classificationPlayers[6].PlayerName);
            //viewModel.PlayersTeamA.Add(classificationPlayers[9].PlayerName);

            //string formatTeamB = "1=GK_{0}t%201_1_388_174&2=ML_{1}%207_7_189_64&3=DM_{2}%204_4_267_180&4=FC_{3}%2010_10_75_173&5=MR_{4}%206_6_175_296&6=MLA___204_64&7=MCL___222_138&8=MCR___222_211&9=MRA___204_284&10=FCL___98_138&11=FCR___98_211&c2=ffffff&c3=ffffff&output=embed";

            //viewModel.TeamB = string.Format(principalURL_teamB + formatTeamB,
            //    classificationPlayers[1].PlayerName,
            //    classificationPlayers[2].PlayerName,
            //    classificationPlayers[4].PlayerName,
            //    classificationPlayers[7].PlayerName,
            //    classificationPlayers[8].PlayerName);

            //viewModel.PlayersTeamB.Add(classificationPlayers[1].PlayerName);
            //viewModel.PlayersTeamB.Add(classificationPlayers[2].PlayerName);
            //viewModel.PlayersTeamB.Add(classificationPlayers[4].PlayerName);
            //viewModel.PlayersTeamB.Add(classificationPlayers[7].PlayerName);
            //viewModel.PlayersTeamB.Add(classificationPlayers[8].PlayerName);

            return RedirectToAction("Resume", new { @season = viewModel.Season, @gameType = viewModel.GameType });
        }
コード例 #3
0
        public ActionResult SetFinalteams(GamesViewModel viewModel)
        {
            List<PlayerConfirmation> tenPlayers = viewModel.PlayerConfirmations.Where(p => p.GoToGame.Equals(true)).ToList<PlayerConfirmation>();
            List<PlayersToGame> classificationPlayers = AddTeams(tenPlayers);
            List<PlayersToGame> goalsTeamA = new List<PlayersToGame>();
            List<PlayersToGame> goalsTeamB = new List<PlayersToGame>();

            if (classificationPlayers != null && classificationPlayers.Count() > 0)
            {
                classificationPlayers = classificationPlayers
                    .OrderByDescending(p => p.Points)
                    .ThenByDescending(p => p.Goals)
                    .ThenBy(p => p.IsSubstitute)
                    .ThenByDescending(p => p.NumGames)
                    .ThenBy(p => p.PlayerName)
                    .ToList<PlayersToGame>();

                goalsTeamA = BuildTeamGoals(classificationPlayers, 'A');
                goalsTeamB = BuildTeamGoals(classificationPlayers, 'B');

                SaveTeams(classificationPlayers, 1, 1);
                viewModel.LinkTeamA = BuildTeam(classificationPlayers, 'A');
                viewModel.GoalsTeamA = goalsTeamA;
                viewModel.GoalsTeamB = goalsTeamB;

                viewModel.LinkTeamB = BuildTeam(classificationPlayers, 'B');
                viewModel.HasTeams = true;

                ClosePresencesInGame(viewModel.GameType);

                TempData["Game"] = viewModel;

            }

            return RedirectToAction("Resume", new { @season = viewModel.Season, @gameType = viewModel.GameType });
        }
コード例 #4
0
        // GET: Sunday
        public ActionResult Resume(string season, string gameType)
        {
            if (string.IsNullOrEmpty(season) && string.IsNullOrEmpty(gameType))
            {
                return RedirectToAction("HomePage");
            }

            GamesViewModel sundayVM = new GamesViewModel();

            if (TempData["Game"] != null)
            {
                sundayVM = TempData["Game"] as GamesViewModel;
            }
            else
            {
                List<PlayersToGame> lastTeams = GetFinalTeams(gameType);

                if (lastTeams != null && lastTeams.Count() > 0)
                {
                    sundayVM.hasOpengames = true;
                    sundayVM.HasTeams = true;
                    sundayVM.Season = season;
                    sundayVM.GameType = gameType;
                    lastTeams = lastTeams
                   .OrderByDescending(p => p.Points)
                .ThenByDescending(p => p.Goals)
                .ThenBy(p => p.IsSubstitute)
                .ThenByDescending(p => p.NumGames)
                .ThenBy(p => p.PlayerName)
                .ToList<PlayersToGame>();

                    sundayVM.LinkTeamA = BuildTeam(lastTeams, 'A');
                    sundayVM.LinkTeamB = BuildTeam(lastTeams, 'B');
                    sundayVM.GoalsTeamA = BuildTeamGoals(lastTeams, 'A');
                    sundayVM.GoalsTeamB = BuildTeamGoals(lastTeams, 'B');
                }
                else
                {
                    sundayVM.hasOpengames = false;
                    sundayVM.HasTeams = false;
                    sundayVM.Season = season;
                    sundayVM.GameType = gameType;
                    sundayVM.Players = GetPlayers(season, gameType);
                    sundayVM.hasOpengames = HasOpenGames(gameType);
                    sundayVM.PlayerConfirmations = new List<PlayerConfirmation>();
                    List<Players_GameType> substitutesList = GetPLayersSubstitues(season, gameType);
                    List<Classification> sundayClassificationFromDB = GetSundayClassification("2016/2017", "Sunday");

                    foreach (Player player in sundayVM.Players)
                    {
                        sundayVM.PlayerConfirmations.Add(new PlayerConfirmation
                        {

                            //GoToGame = (i==2 || i==4) ? true : false,
                            PlayerID = player.ID,
                            PlayerName = player.Name,
                            IsSubstitute = substitutesList.Where(p => p.PlayerID.Equals(player.ID)).ToList<Players_GameType>().Count > 0 ? true : false

                        });

                    };

                    var orderedList = sundayVM.PlayerConfirmations.OrderBy(p => p.IsSubstitute).ThenBy(p => p.PlayerName);
                    sundayVM.PlayerConfirmations = orderedList.ToList<PlayerConfirmation>();
                    sundayVM.Classification = BuildClassification(sundayClassificationFromDB);

                }

            }

            return View(sundayVM);
        }
コード例 #5
0
        public ActionResult InsertGoals(GamesViewModel playerGoals)
        {
            using (ApplicationDbContext ctx = new ApplicationDbContext())
            {
                UpdatePlayerData(playerGoals.GoalsTeamA, playerGoals.GameType, ctx);
                UpdatePlayerData(playerGoals.GoalsTeamB, playerGoals.GameType, ctx);
                SaveResults(playerGoals.GoalsTeamA, playerGoals.GameType, ctx);
                SaveResults(playerGoals.GoalsTeamB, playerGoals.GameType, ctx);

                CloseGame(ctx, playerGoals.GameType);

                ctx.SaveChanges();
            }

            return RedirectToAction("Resume", new { @season = playerGoals.Season, @gameType = playerGoals.GameType });
        }