コード例 #1
0
        public void createControl_CreatedUser( object sender, EventArgs e )
        {
            bool success = false;
            CreateUserWizard cont = null;

            try {
                cont = (CreateUserWizard)sender;

                _RoleProvider.AddUsersToRoles( new string[1] { cont.UserName }, new string[1] { Core.Membership.Roles.REGISTERED } );

                var profileService = new ProfileService( cont.UserName );
                var profile = profileService.GetUserProfile();
                profile.Public = false;
                profile.ButtonSize = DefaultButtonSize;
                profile.FontSize = DefaultFontSize;
                profile.Save();

                success = true;
            }
            catch ( Exception ex ) {
                _Log.WriteFatal( "There was a major error creating a new user with a message of: " + ex.Message );
            }

            //If they successfully create a new user then send a welcome email and take them to the main page
            //  Otherwise it will show them an error or in a fatal case it will take them to Login.
            if ( success && cont != null ) {
                var emailManager = new EmailManager( this.Page );
                emailManager.SendWelcomeEmail( cont.UserName, cont.Password, cont.Email );

                System.Web.Security.FormsAuthentication.RedirectFromLoginPage( cont.UserName, true );
                Response.Redirect( LinkBuilder.DefaultMainLink() );
            }
        }
コード例 #2
0
        public void btnSaveProfile_Click( object sender, EventArgs e )
        {
            IProfileService profileService = new ProfileService( User.Identity.Name );

            bool success = false;
            try {

                var userProfile = profileService.GetUserProfile();
                var user = _MembershipProvider.GetUser( User.Identity.Name );

                if ( txtName.Text != userProfile.Name ) profileService.SaveName( txtName.Text.Trim() );

                if ( txtEmail.Text != user.Email ) {
                    user.Email = txtEmail.Text.Trim();
                    _MembershipProvider.UpdateUser( user );
                }

                profileService.SavePublic( chkPublic.Checked );

                success = true;
            }
            catch ( Exception ex ) {
                _Log.WriteFatal( "THERE WAS AN ERROR SAVING PROFILE ON SETTINGS.ASPX with message: " + ex.Message );
                success = false;
            }

            ValidateSuccess( success, "You have successfully saved your profile.", "There was an error saving your profile." );
            Bind();
        }
コード例 #3
0
        private void Bind()
        {
            IProfileService profileService = new ProfileService( User.Identity.Name );

            var user = _MembershipProvider.GetUser( User.Identity.Name );
            var userProfile = profileService.GetUserProfile();

            txtName.Text = userProfile.Name;
            txtEmail.Text = user.Email;
            lblUserName.Text = userProfile.UserName;

            chkPublic.Checked = userProfile.Public.HasValue ? userProfile.Public.Value : false;
        }
コード例 #4
0
        public override void ProcessRequest( HttpContextBase context )
        {
            HttpRequestBase request = context.Request;
            var w = request.QueryString["width"];
            var f = request.QueryString["fontSize"];
            var userName = request.QueryString["uName"].ToString();
            HttpResponseBase response = context.Response;

            float width, fontSize;
            if ( !( float.TryParse( w, out width ) && float.TryParse( f, out fontSize ) && !string.IsNullOrEmpty(userName) ) ) return;

            var profileService = new ProfileService( userName );
            var profile = profileService.GetUserProfile();

            profile.ButtonSize = width;
            profile.FontSize = fontSize;
            profile.Save();
        }
コード例 #5
0
        private void Bind()
        {
            ResetPanels();

            Guid userId;

            UserName = User.Identity.Name;
            userId = GetUserId();
            var urlSegments = Request.GetFriendlyUrlSegments();

            var segment = urlSegments.FirstOrDefault();

            if ( segment != null && segment != "Year" ) {
                var user = _MembershipProvider.GetUser( segment );

                if ( user == null ) return;

                var otherUserProfileService = new ProfileService( user.UserName );
                var userProfile = otherUserProfileService.GetUserProfile();

                if ( !userProfile.Public.HasValue || ( userProfile.Public.HasValue && userProfile.Public.Value == false ) ) {
                    phPrivate.Visible = true;
                    return;
                }

                userId = new Guid( user.ProviderUserKey.ToString() );
            }
            else if ( segment != null && segment == "Year" ) {
                int year = 0;
                var segmentCount = urlSegments.Count();

                //Parse Year out
                if ( segmentCount > 1 && int.TryParse( urlSegments[1], out year ) ) {

                    //If "only" is in the url then turn all yearboxes off
                    if ( segmentCount > 2 ) {

                        PerformActionOnAllYearBoxes( new Action<YearBoxes>( ( yearBox ) => {
                            yearBox.Off = true;
                        } ) );

                        phYears.Visible = true;
                    }
                }

                var lastTwoDigits = GetLastTwoDigits( year );
                var yearBoxIdToFind = YearBoxBaseId + lastTwoDigits;

                var box = FindControlRecursive( divAllYearBoxes, yearBoxIdToFind );

                //Turns the chosen year box on and into month mode
                if ( box != null ) {
                    YearBoxes chosenBox = (YearBoxes)box;
                    chosenBox.Off = false;
                    chosenBox.MonthMode = true;
                }

                var spanToMove = "#spanYear" + lastTwoDigits;
                //This script moves the year box up to right under the year list.
                //  This is so they are all even on the page after postback
                Page.RegisterStartupScript( "MoveScript", "<script type=\"text/javascript\">  $('#divUnderYearList').append($('" + spanToMove + "') ); </script>" );
            }

            var profileService = new ProfileService( User.Identity.Name );
            var profile = profileService.GetUserProfile();
            ButtonSize = profile.ButtonSize.HasValue ? profile.ButtonSize.Value : DefaultButtonSize;
            FontSize = profile.FontSize.HasValue ? profile.FontSize.Value : DefaultFontSize;

            var listenedShowService = Ioc.GetInstance<IListenedShowService>();
            var listenedShows = listenedShowService.GetByUser( userId );

            List<ShowStatus> shows = new List<ShowStatus>();
            foreach ( var show in listenedShows.ToList() ) {
                shows.Add( new ShowStatus( show.ShowId, show.Status, show.Attended ) );
            }

            //Set the shows on all Year Boxes.
            PerformActionOnAllYearBoxes( new Action<YearBoxes>( ( yearBox ) => {
                yearBox.Shows = shows;
            } ) );
        }