public async Task <IActionResult> GetGroupParticipants(string groupGuid, int?page, int?pageSize) { var creator = await _groupsRepository.Get(groupGuid); return(new OkObjectResult(new { Users = (await _groupsRepository.GetGroupUsers(groupGuid, page, pageSize)) .Select(user => new UserFoundDto(user)), CreatorGuid = creator.Creator.UserGuid })); }
public async Task <Message> SendMessage(string text, string groupGuid, string userGuid, IClientProxy clients) { var sender = await _users.Get(userGuid); if (sender == null) { throw new ArgumentException("Login not found"); } var group = await _groups.Get(groupGuid); if (group == null) { throw new ArgumentException("Group not found"); } var participants = await _groups.GetGroupUsers(groupGuid); if (participants.Count(user => user.UserGuid == sender.UserGuid) < 1) { throw new ArgumentException("User is not in a group"); } var message = new Message() { Group = group, Sender = sender, Text = text, Time = DateTime.Now }; var m = await _messages.Create(message); var incoming = new GroupMessageDto(message); var users = await _groups.GetGroupUsers(groupGuid); foreach (var user in users) { await _pusher.ChatMessage(incoming, user, group, clients); } return(message); }