public async Task <int> UpdateUserToken(int userId, string token) { var user = await FindUser(x => x.Id == userId, errorParameters : userId); user.Token = token; _chatDbContext.Entry(user).State = EntityState.Modified; return(await _chatDbContext.SaveChangesAsync()); }
public async Task SendMessage(string message) { Clients.All.SendMessage(Identity.Name, message); var messageEntity = new Message { Username = Identity.Name, Text = message, Date = DateTimeOffset.UtcNow }; chatContext.Messages.Add(messageEntity); await chatContext.SaveChangesAsync(); }
public async Task <int> SendMessage(MessageDto message) { _chatDbContext.Messages.Add(message.ToMessage()); return(await _chatDbContext.SaveChangesAsync()); }