Exemplo n.º 1
0
        public IActionResult GetPluginProfile(long groupId)
        {
            List <Domain.Socioboard.Helpers.PluginProfile> lstPluginProfile = new List <Domain.Socioboard.Helpers.PluginProfile>();
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
            List <Domain.Socioboard.Models.Groupprofiles> lstGroupprofiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId.Equals(groupId) && (t.profileType == Domain.Socioboard.Enum.SocialProfileType.Facebook || t.profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage || t.profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter)).ToList();

            lstGroupprofiles = lstGroupprofiles.GroupBy(t => t.profileId).Select(g => g.First()).ToList();
            foreach (var item in lstGroupprofiles)
            {
                try
                {
                    if (item.profileType == Domain.Socioboard.Enum.SocialProfileType.Facebook || item.profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage)
                    {
                        Domain.Socioboard.Models.Facebookaccounts _Facebookaccounts = FacebookRepository.getFacebookAccount(item.profileId, _redisCache, dbr);
                        if (_Facebookaccounts != null)
                        {
                            if (!string.IsNullOrEmpty(_Facebookaccounts.AccessToken))
                            {
                                if (_Facebookaccounts.IsActive)
                                {
                                    Domain.Socioboard.Helpers.PluginProfile _sb = new Domain.Socioboard.Helpers.PluginProfile();
                                    _sb.type            = "facebook";
                                    _sb.facebookprofile = _Facebookaccounts;
                                    _sb.twitterprofile  = new Domain.Socioboard.Models.TwitterAccount();
                                    lstPluginProfile.Add(_sb);
                                }
                            }
                        }
                    }
                    if (item.profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter)
                    {
                        Domain.Socioboard.Models.TwitterAccount _TwitterAccount = TwitterRepository.getTwitterAccount(item.profileId, _redisCache, dbr);
                        if (_TwitterAccount != null)
                        {
                            if (_TwitterAccount.isActive)
                            {
                                Domain.Socioboard.Helpers.PluginProfile _sb = new Domain.Socioboard.Helpers.PluginProfile();
                                _sb.type            = "twitter";
                                _sb.twitterprofile  = _TwitterAccount;
                                _sb.facebookprofile = new Domain.Socioboard.Models.Facebookaccounts();
                                lstPluginProfile.Add(_sb);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    return(Ok(lstPluginProfile));
                }
            }
            return(Ok(lstPluginProfile));
        }
Exemplo n.º 2
0
        private static void AddedProfileDetails(Cache redisCache, DatabaseRepository dbr, List <profilesdetail> groupProfiles, Groupprofiles profile)
        {
            switch (profile.profileType)
            {
            case SocialProfileType.Facebook:
            {
                var fbAcc          = FacebookRepository.getFacebookAccount(profile.profileId, redisCache, dbr);
                var profileDetails = new profilesdetail {
                    Fbaccount = fbAcc
                };
                groupProfiles.Add(profileDetails);
                break;
            }

            case SocialProfileType.FacebookFanPage:
            {
                var fbPageAcc      = FacebookRepository.getFacebookAccount(profile.profileId, redisCache, dbr);
                var profileDetails = new profilesdetail {
                    Fbaccount = fbPageAcc
                };
                groupProfiles.Add(profileDetails);
                break;
            }

            case SocialProfileType.Twitter:
            {
                var twtAcc         = TwitterRepository.getTwitterAccount(profile.profileId, redisCache, dbr);
                var profileDetails = new profilesdetail {
                    Twtaccount = twtAcc
                };
                groupProfiles.Add(profileDetails);
                break;
            }

            case SocialProfileType.Instagram:
            {
                var insAcc         = InstagramRepository.getInstagramAccount(profile.profileId, redisCache, dbr);
                var profileDetails = new profilesdetail {
                    Instaaccount = insAcc
                };
                groupProfiles.Add(profileDetails);
                break;
            }

            case SocialProfileType.GPlus:
            {
                var gPlusAcc       = GplusRepository.getGPlusAccount(profile.profileId, redisCache, dbr);
                var profileDetails = new profilesdetail {
                    Gplusaccount = gPlusAcc
                };
                groupProfiles.Add(profileDetails);
                break;
            }

            case SocialProfileType.LinkedIn:
            {
                var linkedInAcc    = LinkedInAccountRepository.getLinkedInAccount(profile.profileId, redisCache, dbr);
                var profileDetails = new profilesdetail {
                    LinkdInaccount = linkedInAcc
                };
                groupProfiles.Add(profileDetails);
                break;
            }

            case SocialProfileType.LinkedInComapanyPage:
            {
                var linkedCompanyAcc = LinkedInAccountRepository.getLinkedinCompanyPage(profile.profileId, redisCache, dbr);
                var profileDetails   = new profilesdetail {
                    LinkdINcompanyaccount = linkedCompanyAcc
                };
                groupProfiles.Add(profileDetails);
                break;
            }

            case SocialProfileType.YouTube:
            {
                var youtubeChannel = GplusRepository.getYTChannel(profile.profileId, redisCache, dbr);
                var profileDetails = new profilesdetail {
                    Ytubeaccount = youtubeChannel
                };
                groupProfiles.Add(profileDetails);
                break;
            }

            case SocialProfileType.GoogleAnalytics:
            {
                var gAAcc          = GplusRepository.getGAAccount(profile.profileId, redisCache, dbr);
                var profileDetails = new profilesdetail {
                    GAaccount = gAAcc
                };
                groupProfiles.Add(profileDetails);
                break;
            }

            case SocialProfileType.Pinterest:
            {
                var pInterestAccountDetail = PinterestRepository.getPinterestAccountDetail(profile.profileId, redisCache, dbr);
                var profileDetails         = new profilesdetail {
                    Pintrestaccount = pInterestAccountDetail
                };
                groupProfiles.Add(profileDetails);
                break;
            }

            case SocialProfileType.GplusPage:
                break;

            case SocialProfileType.Tumblr:
                break;

            case SocialProfileType.FacebookPublicPage:
                break;

            case SocialProfileType.DropBox:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }