public async Task <PendingAddFacebookPagesDto> GetPendingAddPagesAsync(string code, string redirectUri) { string userToken = _fbClient.GetUserToken(code, redirectUri); FbUser me = await _fbClient.GetMe(userToken); IList <FbPage> pages = await _fbClient.GetPages(userToken); List <string> pageIds = pages.Select(t => t.Id).ToList(); var facebookAccounts = _socialAccountService.FindAll() .Where(t => t.SocialUser.Type == SocialUserType.IntegrationAccount && t.SocialUser.Source == SocialUserSource.Facebook && pageIds.Contains(t.SocialUser.OriginalId)) .ToList(); var result = new PendingAddFacebookPagesDto { SignInAs = new FacebookSignInAsDto { Name = me.name, Avatar = me.pic }, Pages = pages.Select(t => new PendingAddFacebookPageDto { FacebookId = t.Id, Name = t.Name, Category = t.Category, Avatar = t.Avatar, AccessToken = t.AccessToken, Link = t.Link, IsAdded = facebookAccounts.Any(m => m.SocialUser.OriginalId == t.Id) }).ToList() }; return(result); }