Пример #1
0
        protected virtual bool EditCore(ControllerContext controllerContext, SubmissionSetting submissionSetting, out string redirectUrl)
        {
            redirectUrl = "";

            var memberAuth = controllerContext.HttpContext.Membership();

            if (memberAuth.GetMember().Identity.IsAuthenticated == false)
            {
                throw new HttpException((int)System.Net.HttpStatusCode.Unauthorized, "");
            }
            var membership = MemberPluginHelper.GetMembership();

            var membershipUser = controllerContext.HttpContext.Membership().GetMembershipUser();

            var editMemberModel = new EditMemberProfileModel();

            bool valid = ModelBindHelper.BindModel(editMemberModel, "", controllerContext, submissionSetting);

            if (valid)
            {
                redirectUrl = editMemberModel.RedirectUrl;
                if (!string.IsNullOrEmpty(redirectUrl))
                {
                    redirectUrl = MemberPluginHelper.ResolveSiteUrl(controllerContext, redirectUrl);
                }

                try
                {
                    _manager.EditMemberProfile(membership, memberAuth.GetMember().Identity.Name, editMemberModel.Email, editMemberModel.Culture,
                                               editMemberModel.TimeZoneId, editMemberModel.PasswordQuestion, editMemberModel.PasswordAnswer, editMemberModel.Profiles);
                    valid = true;
                }
                catch (DataViolationException e)
                {
                    controllerContext.Controller.ViewData.ModelState.FillDataViolation(e.Violations);
                    valid = false;
                }
                catch (Exception e)
                {
                    controllerContext.Controller.ViewData.ModelState.AddModelError("", e.Message);
                    Kooboo.HealthMonitoring.Log.LogException(e);
                    valid = false;
                }
            }
            return(valid);
        }
Пример #2
0
        protected virtual bool EditCore(ControllerContext controllerContext, SubmissionSetting submissionSetting, out string redirectUrl)
        {
            redirectUrl = "";

            var memberAuth = controllerContext.HttpContext.Membership();
            if (memberAuth.GetMember().Identity.IsAuthenticated == false)
            {
                throw new HttpException((int)System.Net.HttpStatusCode.Unauthorized, "");
            }
            var membership = MemberPluginHelper.GetMembership();

            var membershipUser = controllerContext.HttpContext.Membership().GetMembershipUser();

            var editMemberModel = new EditMemberProfileModel();

            bool valid = ModelBindHelper.BindModel(editMemberModel, "", controllerContext, submissionSetting);

            if (valid)
            {
                redirectUrl = editMemberModel.RedirectUrl;
                if (!string.IsNullOrEmpty(redirectUrl))
                {
                    redirectUrl = MemberPluginHelper.ResolveSiteUrl(controllerContext, redirectUrl);
                }

                try
                {
                    _manager.EditMemberProfile(membership, memberAuth.GetMember().Identity.Name, editMemberModel.Email, editMemberModel.Culture,
                        editMemberModel.TimeZoneId, editMemberModel.PasswordQuestion, editMemberModel.PasswordAnswer, editMemberModel.Profiles);
                    valid = true;
                }
                catch (DataViolationException e)
                {
                    controllerContext.Controller.ViewData.ModelState.FillDataViolation(e.Violations);
                    valid = false;
                }
                catch (Exception e)
                {
                    controllerContext.Controller.ViewData.ModelState.AddModelError("", e.Message);
                    Kooboo.HealthMonitoring.Log.LogException(e);
                    valid = false;
                }
            }
            return valid;
        }