Exemple #1
0
        public IActionResult Login(Userdetail tologin)
        {
            if (tologin == null)
            {
                errorMsg = "用户名或密码不能为空";
                return(Redirect(Url.Action("Index", "Home")));
            }
            var model = userService.ShowDetail(tologin.Uid);

            if (model == null || model.Passwod != tologin.Passwod)
            {
                //ViewData["errorMsg"] = "showErrorMsg(\'用户名或密码错误!\');";
                errorMsg = "用户名或密码错误";
                return(Redirect(Url.Action("Index", "Home")));
            }
            model.Passwod = null;
            UserrelationService relationService = new UserrelationService();
            var relation = relationService.ShowDetail(tologin.Uid);
            var user     = new User()
            {
                detail   = model,
                relation = relation
            };
            string json = JsonConvert.SerializeObject(user);

            this.Response.Cookies.Append("user", json);
            return(Redirect(Url.Action("Privacy", "Home")));
        }
        //更新
        public IActionResult Update(Userdetail detail)
        {
            if (userService.ShowDetail(detail.Uid).Uname != detail.Uname)
            {
                var relatonService = new UserrelationService();
                var relation       = relatonService.ShowDetail(detail.Uid);
                relation.Name = detail.Uname;
                relatonService.Update(relation);
            }
            var id = userService.Update(detail);

            return(Redirect(Url.Action("Detail", "_User") + $"?uid={id}"));
        }