Esempio n. 1
0
        protected void objDsEmployer_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
        {
            Employer item        = (Employer)e.InputParameters[0];
            bool     UserCreated = true;



            ProfileCommon profile = ProfileCommon.GetProfile();

            profile.SecurityQuestions.Question1 = txtQuestion1.Text;
            profile.SecurityQuestions.Answer1   = txtAnswer1.Text;
            profile.SecurityQuestions.Question2 = txtQuestion2.Text;
            profile.SecurityQuestions.Answer2   = txtAnswer2.Text;
            try
            {
                profile.Save();
            }
            catch
            {
                UserCreated = false;
            }

            if (UserCreated)
            {
                item.UserID = new Guid(Membership.GetUser().ProviderUserKey.ToString());
                saveImage(item);
            }
            else
            {
                e.Cancel = true;
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         ProfileCommon profile = ProfileCommon.GetProfile();
         txtKeyword.Text = profile.RecentSearch.Keywords;
     }
 }
Esempio n. 3
0
        public static bool CreateUser(string username
                                      , string password, string recoveryEmail
                                      , string question1, string answer1, string question2, string answer2)
        {
            bool           UserCreated = true;
            MembershipUser user        = null;


            if (HttpContext.Current.Session["UserID"] == null)
            {
                if (Membership.GetUser(username) == null)
                {
                    user = Membership.CreateUser(username,
                                                 password,
                                                 recoveryEmail);

                    if (user != null)
                    {
                        Roles.AddUserToRole(username, "Members");

                        /*We need the following method to execute otherwise the
                         * logged in user won't be Initialized correctly
                         */
                        Common.InitializeUser(username, HttpContext.Current);

                        ProfileCommon profile = ProfileCommon.GetProfile();
                        profile.SecurityQuestions.Question1 = question1;
                        profile.SecurityQuestions.Answer1   = answer1;
                        profile.SecurityQuestions.Question2 = question2;
                        profile.SecurityQuestions.Answer2   = answer2;
                        profile.Save();

                        HttpContext.Current.Session["UserID"] = user.ProviderUserKey;
                    }
                    else
                    {
                        UserCreated = false;
                    }
                }
                else // The user has already been created but some information like below can be updated
                {
                    ProfileCommon profile = ProfileCommon.GetProfile();
                    profile.SecurityQuestions.Question1 = question1;
                    profile.SecurityQuestions.Answer1   = answer1;
                    profile.SecurityQuestions.Question2 = question2;
                    profile.SecurityQuestions.Answer2   = answer2;
                    profile.Save();

                    HttpContext.Current.Session["UserID"] = Membership.GetUser(username).ProviderUserKey;
                }
            }

            return(UserCreated);
        }
        protected void btnSearch_Click(object sender, EventArgs e)
        {
            if (txtKeyword.Text != "")
            {
                whereClause = "DD=" + Server.HtmlEncode(txtKeyword.Text);
            }
            if (txtLocation.Text != "")
            {
                whereClause += "&LL=" + Server.HtmlEncode(txtLocation.Text);
            }

            objDSJob.Select();
            lwSearchResult.DataBind();

            ProfileCommon profile = ProfileCommon.GetProfile();

            profile.RecentSearch.Keywords = txtKeyword.Text;
            profile.Save();
        }
Esempio n. 5
0
        public void Profile_OnMigrateAnonymous(object sender, ProfileMigrateEventArgs args)
        {
            ProfileCommon profile          = ProfileCommon.GetProfile();
            ProfileCommon anonymousProfile = ProfileCommon.GetProfile(args.AnonymousID);

            if (anonymousProfile.RecentSearch.Keywords != null)
            {
                profile.RecentSearch.Keywords = anonymousProfile.RecentSearch.Keywords;
            }


            ////////
            // Delete the anonymous profile. If the anonymous ID is not
            // needed in the rest of the site, remove the anonymous cookie.

            ProfileManager.DeleteProfile(args.AnonymousID);
            AnonymousIdentificationModule.ClearAnonymousIdentifier();

            // Delete the user row that was created for the anonymous user.
            Membership.DeleteUser(args.AnonymousID, true);
        }