Esempio n. 1
0
        /// <summary>
        /// 保存手机号.
        /// </summary>
        /// <param name="mobile">
        /// The mobile.
        /// </param>
        /// <param name="code">
        /// The code.
        /// </param>
        /// <returns>
        /// The <see cref="JsonResult"/>.
        /// </returns>
        public JsonResult SaveMobile(string mobile, string code)
        {
            try
            {
                var coderesult = this.Session[mobile];
                if (code != (string)coderesult)
                {
                    return this.Json(new AjaxResponse(0, "验证码错误!"));
                }

                var userID = this.GetUserID();
                if (userID <= 0)
                {
                    return this.Json(new AjaxResponse(0, "未登录!"));
                }

                var userService = new UserService();
                userService.ModifyMobile(mobile, userID);
                return this.Json(new AjaxResponse(1, "成功!"));
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message, exception);
            }
        }