コード例 #1
0
ファイル: ModifyController.cs プロジェクト: mayafanga/NETcode
        [HttpGet]//建议把查询按钮去掉用GET请求
        public ActionResult FindUserNickNamePage()
        {
            HttpCookie loginUserCookie = Request.Cookies["loginUserInfo"];//登录用户的Cookie

            if (loginUserCookie != null)
            {
                string userAccount = Request.QueryString["userAccount"];//账号
                //string userAccount = "164804073";
                if (userAccount != null)
                {
                    try
                    {
                        var userInfo = userService.FindNickName(userAccount).FirstOrDefault();
                        if (userInfo != null)
                        {
                            userNickName = userInfo.vcNickName;//昵称
                            try
                            {
                                var personInfo = personalinformationService.LoadEntities(personalinformation => true).ToList();
                                foreach (var item in personInfo)
                                {
                                    if (userInfo.ID == item.iUserID)
                                    {
                                        userName = item.vcName;
                                        status   = "ok";
                                    }
                                }
                            }
                            catch (Exception)
                            {
                                status = "fail";
                                mess   = "网络连接不稳定,请稍后再试";
                            }
                        }
                        else
                        {
                            mess   = "查询不到该用户";
                            status = "fail";
                        }
                    }
                    catch (Exception)
                    {
                        mess   = "网络连接不稳定,请稍后再试";
                        status = "fail";
                    }
                }
                else
                {
                    mess   = "请输入账号";
                    status = "fail";
                }
            }
            else
            {
                mess   = "请先登录";
                status = "fail";
            }
            if (status == "fail")
            {
                result = "{" + "\"" + "status" + "\"" + ":" + "\"" + status + "\"" + "," + "\"" + "msg" + "\"" + ":" + "\"" + mess + "\"" + "}";
            }
            if (status == "ok")
            {
                result = "{" + "\"" + "status" + "\"" + ":" + "\"" + status + "\"" + "," + "\"" + "nickName" + "\"" + ":" + "\"" + userNickName + "\"" + "," + "\"" + "userName" + "\"" + ":" + "\"" + userName + "\"" + "}";
            }
            return(Content(result));
        }