public async Task <ServerResponse <List <FriendViewModel> > > GetRequestsFriendsAsync(FriendFilterRequest friendFilterRequest)
 {
     return(AOResultToServerResponse(await _friendService.GetFriendsByRequestFlag(AccountId, EFriendRequestFlag.None, friendFilterRequest)));
 }
 public async Task <ServerResponse <List <FriendViewModel> > > GetSeacrhFriendsAsync(FriendFilterRequest friendFilterRequest)
 {
     return(AOResultToServerResponse(await _friendService.GetSearchFriendsAsync(AccountId, friendFilterRequest)));
 }
Esempio n. 3
0
        public async Task <AOResult <List <FriendViewModel> > > GetFriendsByRequestFlag(int accountId, EFriendRequestFlag eFriendRequestFlag, FriendFilterRequest friendFilterRequest)
        {
            return(await BaseInvokeAsync(async() =>
            {
                var friends = _myHelperDbContext.Friends
                              .Include(x => x.RequestedBy)
                              .Include(x => x.RequestedTo)
                              .Where(x =>
                                     (x.RequestedById == accountId || x.RequestedToId == accountId) &&
                                     x.FriendRequestFlag == eFriendRequestFlag);

                friends = FilterFriends(friends, accountId, friendFilterRequest);

                friends = FetchItems(friends, friendFilterRequest);

                return AOBuilder.SetSuccess(friends.MapFriendsToViewModels(accountId));
            }));
        }
Esempio n. 4
0
 public async Task <ServerResponse <List <FriendViewModel> > > GetMyFriendsAsync(FriendFilterRequest friendFilterRequest)
 {
     return(await _friendService.GetFriendsByRequestFlag(AccountId, EFriendRequestFlag.Approved, friendFilterRequest));
 }
Esempio n. 5
0
        public async Task <AOResult <List <FriendViewModel> > > GetSearchFriendsAsync(int accountId, FriendFilterRequest friendFilterRequest)
        {
            return(await BaseInvokeAsync(async() =>
            {
                var friends = _myHelperDbContext.Friends
                              .Where(x => x.RequestedById == accountId || x.RequestedToId == accountId)
                              .Select(x => x.RequestedById == accountId ? x.RequestedToId : x.RequestedById);

                var searchFriends = _myHelperDbContext.AppUsers.Where(x => !friends.Contains(x.Id) && x.Id != accountId);

                searchFriends = FilterSearchFriends(searchFriends, friendFilterRequest);

                searchFriends = FetchItems(searchFriends, friendFilterRequest);

                return AOBuilder.SetSuccess(await searchFriends.ToAsyncEnumerable().Select(x => _mapper.Map <AppUser, FriendViewModel>(x)).ToList());
            }));
        }