Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(string id)
        {
            var user = await _userManage.FindByIdAsync(id);

            if (user == null)
            {
                return(Redirect("Index"));
            }
            var claims = await _userManage.GetClaimsAsync(user);

            var mode = new EditModel
            {
                email     = user.Email,
                id        = user.Id,
                user_name = user.UserName,
                claims    = claims.Select(x => x.Value).ToList()
            };

            return(View(mode));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(EditModel args)
        {
            var user = await _userManage.FindByIdAsync(args.id);

            if (user == null)
            {
                return(Redirect("Edit"));
            }
            user.UserName = args.user_name;
            user.Email    = args.email;
            var result = await _userManage.UpdateAsync(user);

            if (result.Succeeded)
            {
                return(RedirectToAction("Index"));
            }
            foreach (var item in result.Errors)
            {
                ModelState.AddModelError(string.Empty, "更新条目出错");
            }
            return(View(user));
        }