protected void adminSuspendUserController(object sender, EventArgs e) { registrationErrorHandler suspendHandler = new registrationErrorHandler(); if (suspendUserField.Text == "") { suspendHandler.emptyUserName(); } // Fetch the user object that needs to be suspended user suspendedUser = fetchUserObject(suspendUserField.Text); if (suspendUserField.Text != "") { if (suspendedUser == null) { suspendHandler.userNameNotExists(); } } if (suspendHandler.error == "") { // Change user to suspended status suspendedUser.setStatus(1); // Write back the user object to database currAdmin.suspendUser(suspendedUser); adminDialog.Visible = false; Session["success"] = "adminSuspendUser"; Response.Redirect("main.aspx"); } else { adminDialog.InnerHtml = suspendHandler.error; adminDialog.Visible = true; } }
protected void adminEditUserController(object sender, EventArgs e) { registrationErrorHandler editHandler = new registrationErrorHandler(); if (editUserID.Text == "") { editHandler.emptyUserName(); } if (editPassword.Text == "") { editHandler.emptyPassword(); } if (editRealName.Text == "") { editHandler.emptyRealName(); } if (editEmail.Text == "") { editHandler.emptyEmail(); } else if (!editEmail.Text.Contains("@")) { editHandler.invalidEmail(); } if (editPhone.Text == "") { editHandler.emptyPhoneNumber(); } if (!editPhone.Text.All(char.IsDigit)) { editHandler.invalidPhoneNumber(); } if (editDesc.Text == "") { editHandler.emptyDescription(); } // Fetch the user object from database user targetUser = fetchUserObject(editUserID.Text); if (targetUser == null) { editHandler.userNameNotExists(); } if (editHandler.error == "") { // Edit the user object based on the provided fields targetUser.setPassword(editPassword.Text); targetUser.setName(editRealName.Text); targetUser.setEmail(editEmail.Text); targetUser.setPhoneNumber(int.Parse(editPhone.Text)); targetUser.setPersonalDescription(editDesc.Text); targetUser.setStatus(int.Parse(ddEditStat.SelectedValue)); currAdmin.editUser(targetUser); adminDialog.Visible = false; Session["success"] = "adminEditUser"; Response.Redirect("main.aspx"); } else { adminDialog.InnerHtml = editHandler.error; adminDialog.Visible = true; } }