コード例 #1
0
        public IActionResult UpdateUser(int id, UserDetail ud)
        {
            UserMethod um    = new UserMethod();
            int        i     = 0;
            string     error = "";

            ud.Id         = id;
            i             = um.UpdateUser(ud, out error);
            ViewBag.error = error;
            if (i == 1)
            {
                string     usr         = HttpContext.Session.GetString("currentuser");
                UserDetail currentUser = JsonConvert.DeserializeObject <UserDetail>(usr);
                currentUser.Username = ud.Username;
                currentUser.Password = ud.Password;
                usr = JsonConvert.SerializeObject(currentUser);
                HttpContext.Session.SetString("currentuser", usr);
                return(RedirectToAction("UserSettings"));
            }
            else
            {
                return(View());
            }
        }