public async Task <IActionResult> Socials() { var user = await _userManager.GetUserAsync(User); if (user == null) { ModelState.AddModelError("", "No such user exists!"); return(View()); } var model = new SocialsViewModel { FbUrl = user.FbUrl, TwitterUrl = user.TwitterUrl, LinkedInUrl = user.LinkedInUrl, GithubUrl = user.GithubUrl }; return(View(model)); }
public async Task <IActionResult> Socials(SocialsViewModel model) { if (!ModelState.IsValid) { ModelState.AddModelError("", "Something went wrong!"); return(View(model)); } var user = await _userManager.GetUserAsync(User); if (user == null) { ModelState.AddModelError("", "Something went wrong!"); return(View(model)); } user.TwitterUrl = model.TwitterUrl; user.FbUrl = model.FbUrl; user.LinkedInUrl = model.LinkedInUrl; user.GithubUrl = model.GithubUrl; await _userManager.UpdateAsync(user); return(RedirectToAction(nameof(ManageController.Socials), "Manage")); }