public async Task <IActionResult> Create(GeneralChatMessage message) { if (ModelState.IsValid) { message.UserName = User.Identity.Name; var sender = await _userManager.GetUserAsync(User); message.UserId = sender.Id; message.UserEmail = sender.Email; await _repository.AddMessage(message); await _repository.SaveChanges(); return(Ok()); } return(BadRequest()); }
public async Task SendMessage(GeneralChatMessage message) => await Clients.All.SendAsync("Send", message);