示例#1
0
        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());
        }
示例#2
0
 public async Task SendMessage(GeneralChatMessage message) =>
 await Clients.All.SendAsync("Send", message);