示例#1
0
        public async Task <IActionResult> Edit(ViewModels.EditUser model)
        {
            if (ModelState.IsValid)
            {
                Models.User user = await _userManager.FindByIdAsync(model.Id);

                if (user != null)
                {
                    user.Nick = model.Nick;

                    var result = await _userManager.UpdateAsync(user);

                    if (result.Succeeded)
                    {
                        return(RedirectToAction("Info"));
                    }
                    else
                    {
                        foreach (var error in result.Errors)
                        {
                            ModelState.AddModelError(string.Empty, error.Description);
                        }
                    }
                }
            }
            return(View(model));
        }
示例#2
0
        public async Task <IActionResult> Edit()
        {
            var user = await _userManager.FindByEmailAsync(User.Identity.Name);

            if (user == null)
            {
                return(NotFound());
            }
            ViewModels.EditUser model = new ViewModels.EditUser {
                Id = user.Id, Email = user.Email, Nick = user.Nick
            };
            return(View(model));
        }