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

                Dictionary <String, int> permissionChange = tournament.PermissionAction(account.Model.AccountID, targetUser, action);
                if (permissionChange == null)
                {
                    status  = false;
                    message = "An unexpected error occured";
                }
                else
                {
                    data = new
                    {
                        permissions = permissionChange,
                        isCheckedIn = tournament.isUserCheckedIn(targetUser),
                        targetUser  = targetUser
                    };
                    message = "Permissions are updated";
                    status  = true;
                }
            }
            else
            {
                message = "You must be logged in to do this action";
            }

            return(BundleJson());
        }
コード例 #2
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());
        }