private bool SaveAccount() { string newUserName = UserName.Text.Trim(); if (Page.IsValid && ValidateNewUserName(newUserName)) { //UPDATE ACCOUNT SETTINGS _User.UserName = newUserName; _User.Email = Email.Text; _User.PrimaryAddress.Email = Email.Text; // PREVENT DISABLING OF YOUR OWN ACCOUNT if (_User.Id != AbleContext.Current.UserId) { _User.IsApproved = !IsDisabled.Checked; ShowHideDisabledAlert(); } // UPDATE AFFILIATE ASSOCIATION int affliateId = AlwaysConvert.ToInt(Affiliate.SelectedValue, 0); _User.Affiliate = AffiliateDataSource.Load(affliateId); _User.AffiliateReferralDate = LocaleHelper.LocalNow; // UPDATE TAX EXEMPTIONS _User.TaxExemptionType = (TaxExemptionType)AlwaysConvert.ToInt(TaxExemptionType.SelectedValue); _User.TaxExemptionReference = TaxExemptionReference.Text; // SAVE USER SETTINGS _User.Save(); return(true); } return(false); }
protected void Page_Load(object sender, EventArgs e) { _AffiliateAccounts = UserDataSource.LoadUserAffiliateAccounts(AbleContext.Current.User.Id); //IF SELEF SIGNUP IS NOT ALLOWED AND AFFILIATE IS NOT REGISTERED THEN NO ACCESS TO THIS PAGE if (!AbleContext.Current.Store.Settings.AffiliateAllowSelfSignup && _AffiliateAccounts.Count == 0) { Response.Redirect("MyAccount.aspx"); } //IF NO EXISTING AFFILIATE ACCOUNT THEN ENABLE SIGNUP if (_AffiliateAccounts.Count == 0) { AffiliateForm1.Visible = true; AffiliateInfoPanel.Visible = false; } //IF HAVE REGISTED AFFILIATE ACCOUNTS THEN SHOW THEM IN DROPDOWN else { AffiliateForm1.Visible = false; AffiliateInfoPanel.Visible = true; trAffiliateReport.Visible = true; int affiliateId = 0; if (!Page.IsPostBack && _AffiliateAccounts.Count > 1) { AffiliateAccountList.DataSource = _AffiliateAccounts; AffiliateAccountList.DataBind(); trMultiAccounts.Visible = true; } else if (!Page.IsPostBack && _AffiliateAccounts.Count == 1) { _Affiliate = _AffiliateAccounts[0]; trMultiAccounts.Visible = false; } if (_AffiliateAccounts.Count > 1) { affiliateId = AlwaysConvert.ToInt(AffiliateAccountList.SelectedValue); _Affiliate = AffiliateDataSource.Load(affiliateId); } else if (_AffiliateAccounts.Count == 1) { _Affiliate = _AffiliateAccounts[0]; } if (!Page.IsPostBack && _Affiliate != null) { BindAffiliateReport(); } HiddenAffiliateId.Value = _Affiliate.Id.ToString(); } }
/// <summary> /// Initializes the user context for this token. /// </summary> /// <param name="context">The HttpContext to obtain the user data from</param> public void InitUserContext(HttpContext context) { //INITIALIZE THE TOKEN FOR THIS REQUEST if (context != null) { //GET THE USER CONTEXT HttpRequest request = context.Request; if (request.IsAuthenticated) { //FOR MULTISTORE, IF AUTHENTICATED MAKE SURE THE USER IS VALID FOR THE STORE _User = UserDataSource.LoadForUserName(context.User.Identity.Name); if ((_User == null) || (_User.StoreId != this.StoreId)) { //store mismatch, expire the forms ticket User.Logout(); //redirect to this page to start over context.Response.Redirect(request.RawUrl, true); } } else { _User = UserDataSource.LoadForUserName(request.AnonymousID, true); } // UPDATE LAST ACTIVITY DATE _User.LastActivityDate = LocaleHelper.LocalNow; // CHECK FOR AN AFFILIATE INDICATOR Affiliate affiliate = AffiliateDataSource.Load(AlwaysConvert.ToInt(context.Request.QueryString[Store.GetCachedSettings().AffiliateParameterName])); if (affiliate != null && affiliate.AffiliateId != _User.AffiliateId) { // A VALID AFFILIATE WAS PASSED AND IS NOT THE ONE ASSOCIATED WITH USER // SHOULD WE UPDATE THE USER? StoreSettingCollection settings = Store.GetCachedSettings(); if (settings.AffiliateReferralRule == ReferralRule.NewSignupsOrExistingUsersOverrideAffiliate || _User.AffiliateId == 0) { // THE RULE IS TO ALWAYS OVERRIDE // OR AN EXISTING USER WITH NO AFFILIATE SET WITH EXISTING USERS NO OVERRIDE OPTION // (IF IT WERE A NEW USER CREATED BY THIS REQUEST, AFFILIATEID WOULD ALREADY BE SET) // AFFILIATE SHOULD BE UPDATED FOR THE TARGET USER _User.AffiliateId = affiliate.AffiliateId; _User.AffiliateReferralDate = _User.LastActivityDate; } } this.UserId = _User.UserId; if (_User.UserId != 0) { _User.Save(); } } }
protected void Page_Init(object sender, EventArgs e) { User user = AbleContext.Current.User; Affiliate affiliate = AffiliateDataSource.Load(AlwaysConvert.ToInt(Request.QueryString["AffiliateId"])); if (affiliate == null || affiliate.Group == null || !user.IsInGroup(affiliate.GroupId)) { Response.Redirect("~/Members/MyAffiliateAccount.aspx"); } AffiliateForm.Affiliate = affiliate; }
protected void Page_Load(object sender, System.EventArgs e) { _AffiliateId = AlwaysConvert.ToInt(Request.QueryString["AffiliateId"]); _Affiliate = AffiliateDataSource.Load(_AffiliateId); if (_Affiliate == null) { Response.Redirect("Default.aspx"); } InstructionText.Text = string.Format(InstructionText.Text, AbleContext.Current.Store.Settings.AffiliateParameterName, _AffiliateId, GetHomeUrl()); if (!Page.IsPostBack) { InitEditForm(); } Caption.Text = string.Format(Caption.Text, _Affiliate.Name); }