public GetGroupChatInfoResponse GetGroupChatInfo(ISession session, GetGroupChatInfoRequest request)
        {
            var response  = request.CreateResponse <GetGroupChatInfoResponse>();
            var groupChat = _groupChatsRepository.GetChat(request.GroupId);

            if (!HasAccess(groupChat, session.UserId))
            {
                response.Success = false;
                response.Error   = Errors.OperationIsNotPermitted;
                return(response);
            }

            //TODO: AutoMapper
            response.GroupInfo = new GroupInfo
            {
                Avatar       = groupChat.Avatar,
                GroupId      = groupChat.GroupId,
                CreatedAt    = groupChat.CreatedAt,
                Name         = groupChat.Name,
                OwnerId      = groupChat.OwnerId,
                Participants = groupChat.Participants
                               .Select(p => new ClientDto.Entities.GroupChatParticipant {
                    UserId = p.UserId, Avatar = p.Avatar, Devices = p.Devices, Name = p.Name
                })
                               .ToList()
            };

            return(response);
        }
Esempio n. 2
0
 public Task <GetGroupChatInfoResponse> GetGroupChatInfo(GetGroupChatInfoRequest request)
 {
     return(_connectionManager.SendRequestAndWaitResponse <GetGroupChatInfoResponse>(request));
 }