public IActionResult UserPrivateChat(string userName) { var name = userName; var creatorId = _userManager.GetUserId(User); string user = _userManager.GetUserName(User); string groupName = userName + user; Group group = new Group { CreatorId = creatorId, GroupName = groupName }; if (ModelState.IsValid) { if (_groupHandler.GetByName(groupName) == null) { int _id = _groupHandler.Create(group); string url = "https://" + HttpContext.Request.Host + "/Chat/Users/" + _id.ToString() + "?userName="******"ReceiveMessageNotify", user, "You were invited to a private chat: "); _hubContext.Clients.User(userName).SendAsync("ReceiveMessageUser", url); return(RedirectToAction("Users", "Chat", new { id = _id, userName = name })); } else { var group1 = _groupHandler.GetByName(groupName); int _id = group1.Id; string url = "https://" + HttpContext.Request.Host + "/Chat/Users/" + _id.ToString() + "?userName="******"ReceiveMessageNotify", user, "You were invited to a private chat: "); _hubContext.Clients.User(userName).SendAsync("ReceiveMessageUser", url); return(RedirectToAction("Users", "Chat", new { id = _id, userName = name })); } } else { return(RedirectToAction(nameof(ChatUsers))); } }