コード例 #1
0
        //testing

        public IActionResult testing()
        {
            //Account account = _friendsRepository.GetFriendById(9025);
            //return Ok(account);
            //return Ok(_accountDetailRepository.GetDatasFriend(9025));
            //return Ok(_accountDetailRepository.GetDatasPublic(3024, 9025));
            //return Ok(_searchRepository.SearchFriendsAccounts(_user.Id, "pe"));

            int currentAccountId  = 1;
            int searchedAccountId = 2;

            if (currentAccountId != searchedAccountId)
            {
                if (_friendsRepository.IsFriends(currentAccountId, searchedAccountId)) //friends true
                {
                    return(Ok(_accountDetailRepository.GetDatasFriend(searchedAccountId)));
                }
                else //not friends
                {
                    return(Ok(_accountDetailRepository.GetDatasPublic(currentAccountId, searchedAccountId)));
                }
            }
            else //view own profile
            {
                return(Ok(_accountDetailRepository.GetDatasOwn(searchedAccountId)));
            }
        }
コード例 #2
0
 public IActionResult GetAccountDatas(int currentAccountId, int searchedAccountId)
 {
     if (currentAccountId != searchedAccountId)
     {
         if (_friendsRepository.IsFriends(currentAccountId, searchedAccountId)) //friends true
         {
             return Ok(_accountDetailRepository.GetDatasFriend(searchedAccountId));
         }
         else //not friends
         {
             return Ok(_accountDetailRepository.GetDatasPublic(currentAccountId, searchedAccountId));
         }
     }
     else //view own profile
     {
         return Ok(_accountDetailRepository.GetDatasOwn(searchedAccountId));
     }
 }
コード例 #3
0
        public ICollection <SearchAccount> SearchAccounts(int currentUserId, string term)
        {
            //final search results
            List <SearchAccount> results = new List <SearchAccount>();

            ICollection <int> accountIdList = _context.Accounts.Where(a => a.Fullname.Contains(term))
                                              .OrderBy(a => a.Name)
                                              .Select(a => a.Id)
                                              .ToList();

            foreach (var itemId in accountIdList)
            {
                if (currentUserId != itemId)                                 //don't show current user 2x
                {
                    if (_friendsRepository.IsFriends(currentUserId, itemId)) //friends
                    {
                        SearchAccount searchItem = _accountDetailRepository.GetDatasFriend(itemId);
                        if (searchItem != null)
                        {
                            results.Add(searchItem);
                        }
                    }
                    else //not friends
                    {
                        SearchAccount searchItem = _accountDetailRepository.GetDatasPublic(currentUserId, itemId);
                        if (searchItem != null)
                        {
                            results.Add(searchItem);
                        }
                    }
                }
                else //search own profile
                {
                    SearchAccount searchItem = _accountDetailRepository.GetDatasOwn(itemId);
                    if (searchItem != null)
                    {
                        results.Add(searchItem);
                    }
                }
            }

            return(results);
        }