// GET: User/Edit/{id} public async Task <ActionResult> Edit(Guid id) { var user = await _userRepository.GetUserById(id); var model = new SaveUserFormModel { Id = id, Name = user.Name, Email = user.Email, UserName = user.UserName, IsInactive = user.Inactive }; return(View(model)); }
public async Task <ActionResult> Edit(Guid id, [FromForm] SaveUserFormModel model) { if (!ModelState.IsValid) { model.Id = id; return(View(nameof(Edit), model)); } var user = await _userRepository.GetUserById(id); user.Email = model.Email; user.Name = model.Name; user.UserName = model.UserName; var result = await _userRepository.SaveUser(user); if (result.Succeeded) { return(RedirectToAction(nameof(Index))); } model.Id = id; AddErrors(result); return(View(nameof(Edit), model)); }