コード例 #1
0
        public ActionResult competitionplayersinsert(long id, string name, long challengeid)
        {
            ObservableCollection <PlayerModel> playerCompetitionList = new ObservableCollection <PlayerModel>();

            List <S_Player> playerList;

            if (String.IsNullOrEmpty(name))
            {
                playerList = CompetitionManager.GetPlayersNotInCompetition(id);
            }
            else
            {
                playerList = CompetitionManager.GetPlayersNotInCompetitionByName(id, name);

                if (playerList.Count() == 0)
                {
                    TempData["error"] = "Er zijn geen spelers gevonden.";
                }
                else
                if (playerList.Count() == 1)
                {
                    TempData["message"] = "Er is 1 speler gevonden.";
                }
                else
                {
                    TempData["message"] = "Er zijn " + playerList.Count().ToString() + " spelers gevonden.";
                }
            }

            foreach (S_Player player in playerList)
            {
                S_User user = UserManager.GetUserById(player.userid);

                PlayerModel pm = new PlayerModel();
                pm.Id   = player.userid;
                pm.Name = user.name;
                pm.FrequentBowlernumber = user.frequentbowlernumber;

                playerCompetitionList.Add(pm);
            }

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

            return(View(playerCompetitionList));
        }