public async Task <IActionResult> ChangeUserInfo(ChangeUserInfoViewModel model) { if (ModelState.IsValid) { User user = _chatRepo.GetUserByName(User.Identity.Name); if (user != null) { if (!_chatService.IsValidUserInfo(model.FirstName, model.LastName)) { ModelState.AddModelError(string.Empty, $"Invalid FirstName or LastName"); } await _chatRepo.ChangeUserInfo(user, model.FirstName, model.LastName, model.AvatarUrl); return(RedirectToAction("IM")); } else { ModelState.AddModelError(string.Empty, $"Cannot find user with username {User.Identity.Name}"); } } return(View(model)); }