コード例 #1
0
        public JsonResult NoAccountRegister(int tournamentId, String name, int bracketId)
        {
            if (account.IsLoggedIn())
            {
                Models.Tournament tournament = new Models.Tournament(service, tournamentId);

                // Is an Administrator registering a user?
                if (tournament.IsAdmin(account.Model.AccountID))
                {
                    TournamentUserModel model = tournament.AddUser(name);
                    data = new
                    {
                        user = new
                        {
                            Name             = model.Name,
                            Permission       = model.PermissionLevel,
                            TournamentUserId = model.TournamentUserID,
                            Seed             = tournament.GetUserSeed(bracketId, model.TournamentUserID)
                        },
                        actions = tournament.PermissionAction(account.Model.AccountID, model.TournamentUserID, "default")
                    };
                    if (data != null)
                    {
                        status = true;
                    }
                    message = "User was " + (status ? "" : "not") + " added successfully";
                }
                else
                {
                    message = "You are not allowed to register a user.";
                }
            }
            else
            {
                message = "You need to login first.";
            }

            return(BundleJson());
        }