Exemple #1
0
    protected void btnSumbit_click(object sender, EventArgs e)
    {
        try
        {
            #region Unable to decode referral id, try finding original referral based on email address
            if (badReferralId)
            {
                try
                {
                    Referral badRef = new Referral(email_address.Text);
                    if (badRef.id > 0)
                    {
                        referralid = badRef.id;
                    }
                    else
                    {
                        throw new Exception();
                    }
                }
                catch (Exception ex)
                {
                    logService.LogAppEvent("", @"HarperNET", "Referral", "Unable to link email to referral id (id could not be decoded and email not on file). Using default referrer. Referral id in url: " + Request["ReferralId"] + ", email address entered: " + email_address.Text, ex.Message, ex.StackTrace, "", "Page_Load");
                    
                    Referral defaultReferral = new Referral();
                    defaultReferral.keycode = "POTRIAL";
                    defaultReferral.pubcode = "PO";
                    ReferralOffer offer = new ReferralOffer(defaultReferral.keycode, defaultReferral.pubcode);
                    
                    defaultReferral.ccmember = false;
                    defaultReferral.datecreated = DateTime.Now;
                    defaultReferral.dateexpires = defaultReferral.datecreated.AddMonths(offer.offerexpiresmonths);
                    defaultReferral.friendemail = email_address.Text;
                    defaultReferral.friendname = first_name.Text + " " + last_name.Text;

                    HarperLINQ.tbl_Customer defaultReferrer = new tbl_Customer(ConfigurationManager.AppSettings["default_referrer_username"], true);
                    defaultReferral.memberid = defaultReferrer.cusID;
                    defaultReferral.subscriptionlength = offer.triallengthinmonths;

                    defaultReferral.Save();
                    referralid = defaultReferral.id;
                }
            }
            #endregion

            HarperMembershipService.BaseResponse response = new HarperMembershipService.BaseResponse();
            HarperMembershipService.MembershipService webservice = new HarperMembershipService.MembershipService();

            #region Get selected region
            country = ddlCountries.SelectedValue;
            ISO3166 iso = new ISO3166(country, IdentifierType.Country_Code_Alpha2);
            string sfgcountrycode = iso.SFGCode;

            if (txtRegion.Text != "" && txtRegion.Text != null)
            {
                region = txtRegion.Text;
            }
            else if (txtRegionNotListed.Text != "" && txtRegionNotListed.Text != null)
            {
                region = txtRegionNotListed.Text;
            }
            else
            {
                region = ddlRegion.SelectedValue;
            }
            #endregion

            string erefid = Cryptography.EncryptData(referralid.ToString());
            string epwd = Cryptography.EncryptData(txtPassword.Text);

            #region Redeem the referral
            response = webservice.RedeemReferral(erefid, first_name.Text, last_name.Text, email_address.Text,
                sfgcountrycode, address_line_1.Text, address_line_2.Text, city.Text, region, postal.Text, true, 
                txtUserName.Text, epwd);
            #endregion

            #region Check for errors
            if (response == null)
            {
                throw new Exception(string.Format("Error redeeming referral id {0}, response from SFG was null.", referralid));
            }
            if (response.Messages != null && response.Messages.Count() > 0)
            {
                throw new Exception(response.Messages[0].AhMessage);
            }
            #endregion

            Response.Redirect("~/Referral/RedemptionConfirmation.aspx", false);
        }
        catch (Exception ex)
        {
            logService.LogAppEvent("", @"HarperNET", "Referral", "Error in btnSumbit_click", ex.Message, ex.StackTrace, "", "btnSubmit_click");
            LiteralControl err = new LiteralControl();
            err.Text = "<p class=\"error-message\">An error has occurred.  Please contact the membership department at <a href=\"mailto:[email protected]\">[email protected]</a></p>";
            lblErrorMessage.Controls.Add(err);
            lblErrorMessage.Visible = true;
        }
    }
 partial void DeleteISO3166(ISO3166 instance);
 partial void InsertISO3166(ISO3166 instance);
 partial void UpdateISO3166(ISO3166 instance);
Exemple #5
0
        public ISO3166(object identifier, IdentifierType identifiertype)
        {
            try
            {
                using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
                {
                    ISO3166 iso = null;
                    switch (identifiertype)
                    {
                    case IdentifierType.Id:
                        iso = (from a in context.ISO3166s where a.Id == (int)identifier && a.ParentId == null select a).SingleOrDefault();
                        break;

                    case IdentifierType.Country_Code_Alpha2:
                        iso = (from a in context.ISO3166s where a.Alpha2 == (string)identifier && a.ParentId == null select a).SingleOrDefault();
                        break;

                    case IdentifierType.Country_Code_Alpha3:
                        iso = (from a in context.ISO3166s where a.Alpha3 == (string)identifier && a.ParentId == null select a).SingleOrDefault();
                        break;

                    case IdentifierType.Country_Code_Numeric:
                        iso = (from a in context.ISO3166s where a.Numeric == (int)identifier && a.ParentId == null select a).SingleOrDefault();
                        break;

                    case IdentifierType.Level1_Subdivision_Code:
                        iso = (from a in context.ISO3166s where a.Level1_Subdivision == (string)identifier select a).SingleOrDefault();
                        break;

                    case IdentifierType.Level2_Subdivision_Code:
                        iso = (from a in context.ISO3166s where a.Level2_Subdivision == (string)identifier select a).SingleOrDefault();
                        break;

                    case IdentifierType.Name:
                        iso = (from a in context.ISO3166s where a.Name == (string)identifier select a).SingleOrDefault();
                        break;

                    case IdentifierType.DisplayName:
                        iso = (from a in context.ISO3166s where a.DisplayName == (string)identifier select a).SingleOrDefault();
                        break;
                    }
                    if (iso == null)
                    {
                        throw new ObjectNotFoundException(identifier, identifiertype);
                    }
                    else
                    {
                        this.Id                 = iso.Id;
                        this.Alpha2             = iso.Alpha2;
                        this.Alpha3             = iso.Alpha3;
                        this.Numeric            = iso.Numeric;
                        this.Level1_Subdivision = iso.Level1_Subdivision;
                        this.Level2_Subdivision = iso.Level2_Subdivision;
                        this.Name               = iso.Name;
                        this.ParentId           = iso.ParentId;
                        this.SFGCode            = iso.SFGCode;
                        this.DisplayName        = iso.DisplayName;
                    }
                }
            }
            catch
            {
                throw new IdentifierNotUniqueException(identifier, identifiertype);
            }
        }