Пример #1
0
        public ActionResult competitionranking(long id, string name, long challengeid)
        {
            ObservableCollection <PlayerRankingGridModel> playerRankingModelList         = new ObservableCollection <PlayerRankingGridModel>();
            ObservableCollection <PlayerRankingGridModel> filteredPlayerRankingModelList = new ObservableCollection <PlayerRankingGridModel>();

            List <S_CompetitionPlayers> playerList;

            playerList = CompetitionManager.GetPlayersByCompetition(id);

            if (playerList != null && playerList.Count() > 0)
            {
                S_Competition competition = CompetitionManager.GetCompetition(playerList[0].competitionid);
                S_Challenge   challenge   = ChallengeManager.GetChallengeByCompetition(playerList[0].competitionid);
                List <S_CompetitionPlayersRanking> cprl = CompetitionManager.GetCompetitionPlayersRanking(challenge.id, playerList[0].competitionid, playerList, competition.startdate, competition.enddate);

                foreach (S_CompetitionPlayersRanking cpr in cprl)
                {
                    PlayerRankingGridModel prgm = new PlayerRankingGridModel();
                    prgm.Rank   = cpr.Rank;
                    prgm.UserId = cpr.UserId;
                    prgm.Name   = cpr.Name;
                    prgm.FrequentBowlernumber = cpr.FrequentBowlernumber;
                    prgm.Score = cpr.Score;

                    playerRankingModelList.Add(prgm);
                }

                int rank = cprl.Count();
                if (challengeid != 6)
                {
                    foreach (S_CompetitionPlayers cp in playerList)
                    {
                        bool playerInRanking = false;
                        foreach (PlayerRankingGridModel prgm in playerRankingModelList)
                        {
                            if (prgm.UserId == cp.userid)
                            {
                                playerInRanking = true;
                            }
                        }
                        if (!playerInRanking)
                        {
                            S_User u = UserManager.GetUserById(cp.userid);
                            playerRankingModelList.Add(new PlayerRankingGridModel {
                                Name = u.name, FrequentBowlernumber = u.frequentbowlernumber, Rank = ++rank
                            });
                        }
                    }
                }

                foreach (PlayerRankingGridModel prgm in playerRankingModelList)
                {
                    if (name == null || prgm.Name.ToUpper().Contains(name.ToUpper()))
                    {
                        filteredPlayerRankingModelList.Add(prgm);
                    }
                }
            }

            ViewBag.competitionid = id;
            ViewBag.challengeid   = challengeid;

            return(View(filteredPlayerRankingModelList));
        }
Пример #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Page.MaintainScrollPositionOnPostBack = true;

            if (!this.IsPostBack)
            {
                List <S_Competition> competitions = CompetitionManager.GetCompetitions(true);

                //ListItem item = new ListItem();
                //item.Value = "0";
                //item.Text = "-- Selecteer een competitie --";
                //compCompetitie.Items.Add(item);

                foreach (S_Competition competition in competitions)
                {
                    S_Challenge challenge = ChallengeManager.GetChallenge(competition.challengeid);

                    //item = new ListItem();
                    //item.Value = competition.id.ToString();
                    //item.Text = Conversion.DateToTitle(competition.startdate, competition.enddate) + " : " + challenge.email;
                    //compCompetitie.Items.Add(item);

                    List <S_CompetitionPlayers> playerList;
                    playerList = CompetitionManager.GetPlayersByCompetition(competition.id);

                    if (playerList != null && playerList.Count() > 0)
                    {
                        challenge = ChallengeManager.GetChallengeByCompetition(playerList[0].competitionid);
                        List <S_CompetitionPlayersRanking> cprl = CompetitionManager.GetCompetitionPlayersRanking(challenge.id, playerList[0].competitionid, playerList, competition.startdate, competition.enddate);

                        List <S_CompetitionPlayersRanking> playerRankingModelList = new List <S_CompetitionPlayersRanking>();
                        foreach (S_CompetitionPlayersRanking c in cprl)
                        {
                            playerRankingModelList.Add(c);
                        }


                        int rank = playerRankingModelList.Count();
                        if (challenge.id != 6)
                        {
                            foreach (S_CompetitionPlayers cp in playerList)
                            {
                                bool playerInRanking = false;
                                foreach (S_CompetitionPlayersRanking c in cprl)
                                {
                                    if (c.UserId == cp.userid)
                                    {
                                        playerInRanking = true;
                                    }
                                }
                                if (!playerInRanking)
                                {
                                    S_User u = UserManager.GetUserById(cp.userid);
                                    playerRankingModelList.Add(new S_CompetitionPlayersRanking {
                                        Name = u.name, FrequentBowlernumber = u.frequentbowlernumber, Rank = ++rank
                                    });
                                }
                            }
                        }

                        _content += "<br/><br/><h4>" + Conversion.DateToTitle(competition.startdate, competition.enddate) + " : " + challenge.name + "</h4>";
                        _content += "<table width='100%'>";
                        int row = 0;
                        foreach (S_CompetitionPlayersRanking s in playerRankingModelList)
                        {
                            string background = "lightgrey";
                            if (row++ % 2 == 0)
                            {
                                background = "white";
                            }
                            _content += "<tr><td width='20px' style='background-color:" + background + ";text-align:left;border-bottom: 1px solid black'>" + s.Rank + "</td><td width='120px' style='background-color:" + background + ";text-align:left;border-bottom: 1px solid black'>" + s.Name + "</td><td width='30px' style='background-color:" + background + ";text-align:left;border-bottom: 1px solid black'>" + s.Score + "</td></tr>";
                        }
                        _content += "</table>";
                    }
                }
            }
        }