/// <summary>
        /// 提交表单
        /// </summary>
        /// <returns></returns>
        protected override object OnSubmit()
        {
            var sessionManager = Application.Ioc.Resolve <SessionManager>();
            var session        = sessionManager.GetSession();
            var userManager    = Application.Ioc.Resolve <UserManager>();

            // 修改密码
            if (!string.IsNullOrEmpty(OldPassword) && !string.IsNullOrEmpty(Password))
            {
                if (Password != ConfirmPassword)
                {
                    throw new BadRequestException(new T("Please repeat the password exactly"));
                }
                userManager.ChangePassword(session.ReleatedId, OldPassword, Password);
            }
            // 修改头像
            if (Avatar != null)
            {
                userManager.SaveAvatar(session.ReleatedId, Avatar.OpenReadStream());
            }
            else if (DeleteAvatar)
            {
                userManager.DeleteAvatar(session.ReleatedId);
            }
            return(new {
                message = new T("Saved Successfully"),
                script = ScriptStrings.RefreshAfter(1500)
            });
        }
Example #2
0
        public IActionResult SwitchToLanguage()
        {
            var context  = HttpManager.CurrentContext;
            var language = context.Request.Get <string>("language");

            context.PutCookie(LocaleUtils.LanguageKey, language);
            return(new JsonResult(new { script = ScriptStrings.RefreshAfter(0) }));
        }
            /// <summary>
            /// 提交表单
            /// </summary>
            /// <returns></returns>
            protected override object OnSubmit()
            {
                var sessionManager = Application.Ioc.Resolve <SessionManager>();
                var session        = sessionManager.GetSession();
                var userManager    = Application.Ioc.Resolve <UserManager>();

                if (Avatar != null)
                {
                    userManager.SaveAvatar(session.ReleatedId, Avatar.OpenReadStream());
                }
                else if (DeleteAvatar)
                {
                    userManager.DeleteAvatar(session.ReleatedId);
                }
                return(new {
                    message = new T("Saved Successfully"),
                    script = ScriptStrings.RefreshAfter(1500)
                });
            }