public List <AccountUserDto> ListFriend(Guid idAccountUser)
        {
            try
            {
                var friendRequests = _friendRequestRepository.GetInclude(x => x.UserReciever == idAccountUser || x.UserSender == idAccountUser,
                                                                         includes: sources =>
                                                                         sources.Include(x => x.StatusNavigation)
                                                                         .Include(x => x.FriendRelationship)
                                                                         .ThenInclude(y => y.StatusNavigation)
                                                                         ).FilterRelationship()
                                     .ToList();

                var userFriend = friendRequests.Select(x => x.UserSender)
                                 .Union(friendRequests.Select(x => x.UserReciever))
                                 .Where(x => !x.Equals(idAccountUser))
                                 .ToList();

                var userRequest = _userApiService.GetUsers(userFriend);

                return(userRequest);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #2
0
        public List <ListMessagesResponse> ListMessage(Guid idConversation)
        {
            try
            {
                var result = new List <ListMessagesResponse>();

                var dataConversation = _conversationRepository.GetInclude(x => x.Id == idConversation,
                                                                          includes:
                                                                          source =>
                                                                          source.Include(x => x.Participant)
                                                                          .ThenInclude(y => y.StatusNavigation)
                                                                          .Include(x => x.Messages)
                                                                          .ThenInclude(y => y.StatusNavigation)
                                                                          ).FirstOrDefault();

                if (dataConversation != null)
                {
                    var userSender = dataConversation.Messages
                                     .Select(x => x.Conversation.UserCreator);

                    var userReciever = dataConversation.Messages
                                       .Select(x => x.Participant.UserAccount);

                    var allUserConvensation = _userApiService.GetUsers(userSender.Union(userReciever).Distinct().ToList());

                    dataConversation.Messages.ToList().ForEach(item =>
                    {
                        var tmp = new ListMessagesResponse
                        {
                            Title              = item.Conversation.Title,
                            ContentMessage     = item.ContentMessage,
                            Sender             = allUserConvensation.Where(x => x.Id == item.Conversation.UserCreator).FirstOrDefault(),
                            Reciever           = allUserConvensation.Where(x => x.Id == item.Participant.UserAccount).FirstOrDefault(),
                            StatusConversation = item.Conversation.IsActive == true ? "Open" : "Closed",
                            StatusMessage      = item.StatusNavigation.Name,
                            Status             = item.Participant.StatusNavigation.Name
                        };

                        result.Add(tmp);
                    });
                }

                return(result);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #3
0
        public async Task <IActionResult> Create()
        {
            var users = await _userApiService.GetUsers();

            await _userService.CreateUsers(users);

            return(CreatedAtAction(nameof(Get), new StatusMessage {
                Error = false, Value = "Random users created in the memory"
            }));
        }
Beispiel #4
0
        public IActionResult List(string email, DataSourceRequest command)
        {
            var model = _userApiService.GetUsers(email, command.Page - 1, command.PageSize)
                        .Select(x => x.ToModel())
                        .ToList();
            var gridModel = new DataSourceResult
            {
                Data  = model,
                Total = model.Count
            };

            return(Json(gridModel));
        }