public virtual async Task <IActionResult> UserInfo() { var user = await UserManager.FindByIdAsync(HttpContext.User.GetUserId()); var model = new UserInfoViewModel { FirstName = user.FirstName, LastName = user.LastName, DateOfBirth = user.DateOfBirth, WebSiteUrl = user.WebSiteUrl, PhoneNumber = user.PhoneNumber, AvatarUrl = user.AvatarUrl }; var viewName = await CustomUserInfo.GetUserInfoViewName(CurrentSite, user, HttpContext); await CustomUserInfo.HandleUserInfoGet( CurrentSite, user, model, HttpContext, ViewData); return(View(viewName, model)); }
public virtual async Task <IActionResult> UserInfo(UserInfoViewModel model) { var user = await UserManager.FindByIdAsync(HttpContext.User.GetUserId()); var viewName = await CustomUserInfo.GetUserInfoViewName(CurrentSite, user, HttpContext); bool isValid = ModelState.IsValid; bool customDataIsValid = await CustomUserInfo.HandleUserInfoValidation( CurrentSite, user, model, HttpContext, ViewData, ModelState); if (!isValid || !customDataIsValid) { return(View(viewName, model)); } if (user != null) { user.FirstName = model.FirstName; user.LastName = model.LastName; user.PhoneNumber = model.PhoneNumber; if (model.DateOfBirth.HasValue) { user.DateOfBirth = model.DateOfBirth; } user.RolesChanged = (user.AvatarUrl != model.AvatarUrl); user.WebSiteUrl = model.WebSiteUrl; user.AvatarUrl = model.AvatarUrl; await CustomUserInfo.HandleUserInfoPostSuccess( CurrentSite, user, model, HttpContext ); await UserManager.UpdateAsync(user); this.AlertSuccess(StringLocalizer["Your information has been updated."]); } return(RedirectToAction("Index")); }