Esempio n. 1
0
        public override async Task OnConnectedAsync()
        {
            User currentUser = _chatRepo.GetUserByName(Context.User.Identity.Name);

            await SendStatus(UserStatus.Recently);

            await base.OnConnectedAsync();
        }
Esempio n. 2
0
        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));
        }