internal void setLoggedInUserProfile(int id)
 {
     try {
         loggedInUser = new crud().selectUserProfile(id);
     } catch (requestedDataNotFoundException ex) {
         loggedInUser = null;
     };
 }
 // helpers
 private void fillPersonalData(userProfile user)
 {
     lblUsername.Text = user.userName;
     lblName.Text = user.name;
     lblFirstname.Text = user.firstName;
     lblEmailAddress.Text = user.emailAddress;
     lblNumber.Text = user.number.ToString();
     lblPhone.Text = user.phone;
     lblPlace.Text = user.place;
     lblPostalCode.Text = user.postalCode.ToString();
     lblStreet.Text = user.street;
 }
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            customValidator validator = new customValidator();
            validator.addValidationRule(new customValidationRule(txtUsername, validator.required, null, "Gelieve een gebruikersnaam in te vullen"));
            validator.addValidationRule(new customValidationRule(txtName, validator.required, null, "Gelieve een naam in te vullen"));
            validator.addValidationRule(new customValidationRule(txtFirstName, validator.required, null, "Gelieve een voornaam in te vullen"));
            validator.addValidationRule(new customValidationRule(txtEmailAddress, validator.required, null, "Gelieve een emailadres in te vullen"));
            validator.addValidationRule(new customValidationRule(txtEmailAddress, validator.email, null, "Gelieve een geldig emailadres in te vullen"));
            validator.addValidationRule(new customValidationRule(txtPhone, validator.required, null, "Gelieve een telefoonnummer in te vullen"));
            validator.addValidationRule(new customValidationRule(txtStreet, validator.required, null, "Gelieve een straat in te vullen"));
            validator.addValidationRule(new customValidationRule(txtNumber, validator.required, null, "Gelieve een huisnummer in te vullen"));
            validator.addValidationRule(new customValidationRule(txtNumber, validator.numeric, null, "Gelieve een geheel getal in te vullen"));
            validator.addValidationRule(new customValidationRule(txtPostalCode, validator.required, null, "Gelieve een postcode in te vullen"));
            validator.addValidationRule(new customValidationRule(txtPlace, validator.required, null, "Gelieve een plaats in te vullen"));
            validator.addValidationRule(new customValidationRule(txtPassword, validator.required, null, "Gelieve een wachtwoord in te vullen"));
            validator.addValidationRule(new customValidationRule(txtPasswordRepeat, validator.required, null, "Gelieve een wachtwoord in te vullen"));

            List<string> errors = validator.validate();
            StringBuilder messageText = new StringBuilder();
            if (errors.Count > 0) {
                foreach (string error in errors) {
                    messageText.Append(error + "<br>");
                }

                ((NinaSubscriptionsMaster) this.Master).setMessage(messageClasses.messageError, messageText.ToString());

                return;
            }

            if (txtPassword.Text != txtPasswordRepeat.Text) {
                ((NinaSubscriptionsMaster) this.Master).setMessage(messageClasses.messageError, "De ingegeven wachtwoorden komen niet overeen.");
                return;
            }

            // if all is validated, continue...
            crud crud = new crud();

            userProfile profile = new userProfile();
            profile.userName = txtUsername.Text;
            profile.passwordHash = new PNV_Cryptor.PNV_Cryptor("forgirlswholoveskateboarding", PNV_Cryptor.PNV_Cryptor.EncryptionMethods.TripleDes).EncryptData(txtPassword.Text);
            profile.name = txtName.Text;
            profile.firstName = txtFirstName.Text;
            profile.emailAddress = txtEmailAddress.Text;
            profile.phone = txtPhone.Text;
            profile.street = txtStreet.Text;
            profile.number = Convert.ToInt32(txtNumber.Text);
            profile.postalCode = Convert.ToInt32(txtPostalCode.Text);
            profile.place = txtPlace.Text;
            profile.isAdmin = false;

            if (crud.insertUserProfile(profile) > 0) {
                NinaSubscriptionsMaster master = this.Master as NinaSubscriptionsMaster;
                if (master.login(txtUsername.Text, txtPassword.Text)) {
                    master.setUIatLogin();
                };

                string redirectUrl = "bekijkAanbod.aspx";
                if (Session["urlBeforeLogin"] != null) { redirectUrl = Session["urlBeforeLogin"].ToString(); };

                string redirect = "<a href=\"" + redirectUrl + "\">U heeft zich succesvol geregistreerd. Klik hier om terugkeren naar de vorige pagina.</a>";
                master.setMessage(messageClasses.messageSuccess, redirect);

                clearUI();

            } else {
                NinaSubscriptionsMaster master = this.Master as NinaSubscriptionsMaster;
                master.setMessage(messageClasses.messageError, "Gelieve alle velden correct in te vullen.");
            };
        }
        // initializers
        protected void Page_Load(object sender, EventArgs e)
        {
            NinaSubscriptionsMaster master = this.Master as NinaSubscriptionsMaster;
            master.setHeaderTitle(settingsHelper.get("title_bekijk_inschrijvingen"));

            userProfile user = master.getLoggedInUserProfile();
            if (user == null || user.isAdmin == false) { Response.Redirect("~/Pages/Public/bekijkAanbod.aspx"); };

            if (!IsPostBack) {
                crud crud = new crud();

                // fill course dropdown
                List<course> allCourses = crud.getAllCourses();
                course emptyCourse = new course() { id = 0 };
                allCourses.Insert(0, emptyCourse);
                ddCourseNames.DataSource = allCourses;
                ddCourseNames.DataTextField = "name";
                ddCourseNames.DataValueField = "id";
                ddCourseNames.DataBind();

                List<userProfile> allUserProfiles = crud.getAllUserProfiles();
                userProfile emptyProfile = new userProfile() { id = 0 };
                allUserProfiles.Insert(0, emptyProfile);
                ddUserProfiles.DataSource = allUserProfiles;
                ddUserProfiles.DataTextField = "fullname";
                ddUserProfiles.DataValueField = "id";
                ddUserProfiles.DataBind();

                cldrDates.SelectedDate = DateTime.Now;
            }
        }
        // initializers
        protected void Page_Load(object sender, EventArgs e)
        {
            hfMessage.Value = "";

            loggedInUser = getLoggedInUserProfile();
            setLoggedInUserTitle();

            if (!IsPostBack) {
                setLoginUI();
                setUserNavigation();
                setAdminNavigation();
            }
        }
        protected void lnkBannerLogout_Click(object sender, EventArgs e)
        {
            Session["userID"] = null;
            loggedInUser = null;
            setLoginUI();
            setUserNavigation();
            setAdminNavigation();

            Response.Redirect("~/Pages/Public/bekijkAanbod.aspx");
        }