public IActionResult GetYTChannelsSB(long groupId) { //DatabaseRepository dbr = new Model.DatabaseRepository(_logger, _appEnv); //List<Domain.Socioboard.Models.Groupprofiles> lstGroupprofiles = dbr.Find<Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId).Where(t => t.profileType == Domain.Socioboard.Enum.SocialProfileType.YouTube).ToList(); //List<Domain.Socioboard.Models.YoutubeChannel> lstYoutubeChannel = new List<YoutubeChannel>(); //foreach (var item in lstGroupprofiles) //{ // Domain.Socioboard.Models.YoutubeChannel YTChnl = Repositories.GplusRepository.getYTChannel(item.profileId, _redisCache, dbr); // if (YTChnl != null) // { // lstYoutubeChannel.Add(YTChnl); // } //} //return Ok(lstYoutubeChannel); DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); DatabaseRepository dbr = new Model.DatabaseRepository(_logger, _appEnv); List <Domain.Socioboard.Models.Groupprofiles> lstGrpProfiles = Repositories.GroupProfilesRepository.getGroupProfiles(groupId, _redisCache, dbr); List <Domain.Socioboard.Models.YoutubeChannel> lstYoutubeChannel = new List <Domain.Socioboard.Models.YoutubeChannel>(); foreach (var item in lstGrpProfiles.Where(t => t.profileType == Domain.Socioboard.Enum.SocialProfileType.YouTube)) { Domain.Socioboard.Models.YoutubeChannel YTChnl = Repositories.GplusRepository.getYTChannel(item.profileId, _redisCache, dbr); if (YTChnl != null) { lstYoutubeChannel.Add(YTChnl); } } return(Ok(lstYoutubeChannel)); }
public IActionResult AddProfileToGroup(string profileId, long groupId, long userId, Domain.Socioboard.Enum.SocialProfileType profileType) { DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv); List <Domain.Socioboard.Models.Groupprofiles> lstGroupProfiles = GroupProfilesRepository.getGroupProfiles(groupId, _redisCache, dbr); if (lstGroupProfiles.Where(t => t.profileId.Equals(profileId)).Count() > 0) { return(BadRequest("profile already added")); } else { Domain.Socioboard.Models.Groups grp = dbr.Find <Domain.Socioboard.Models.Groups>(t => t.id == groupId).FirstOrDefault(); if (grp == null) { return(BadRequest("Invalid groupId")); } else { Domain.Socioboard.Models.Groupprofiles grpProfile = new Domain.Socioboard.Models.Groupprofiles(); if (profileType == Domain.Socioboard.Enum.SocialProfileType.Facebook || profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage || profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookPublicPage) { Domain.Socioboard.Models.Facebookaccounts fbAcc = Repositories.FacebookRepository.getFacebookAccount(profileId, _redisCache, dbr); if (fbAcc == null) { return(BadRequest("Invalid profileId")); } if (fbAcc.UserId != userId) { return(BadRequest("profile is added by other user")); } grpProfile.profileName = fbAcc.FbUserName; grpProfile.profileOwnerId = userId; grpProfile.profilePic = "http://graph.facebook.com/" + fbAcc.FbUserId + "/picture?type=small"; grpProfile.profileType = profileType; } else if (profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter) { Domain.Socioboard.Models.TwitterAccount twtAcc = Repositories.TwitterRepository.getTwitterAccount(profileId, _redisCache, dbr); if (twtAcc == null) { return(BadRequest("Invalid profileId")); } if (twtAcc.userId != userId) { return(BadRequest("profile is added by other user")); } grpProfile.profileName = twtAcc.twitterScreenName; grpProfile.profileOwnerId = userId; grpProfile.profilePic = twtAcc.profileImageUrl; grpProfile.profileType = Domain.Socioboard.Enum.SocialProfileType.Twitter; } else if (profileType == Domain.Socioboard.Enum.SocialProfileType.GPlus) { Domain.Socioboard.Models.Googleplusaccounts gplusAccount = Repositories.GplusRepository.getGPlusAccount(profileId, _redisCache, dbr); if (gplusAccount == null) { return(BadRequest("Invalid ProfileId")); } if (gplusAccount.UserId != userId) { return(BadRequest("profile is added by other user")); } grpProfile.profileName = gplusAccount.GpUserName; grpProfile.profileOwnerId = userId; grpProfile.profilePic = gplusAccount.GpProfileImage; } else if (profileType == Domain.Socioboard.Enum.SocialProfileType.GoogleAnalytics) { Domain.Socioboard.Models.GoogleAnalyticsAccount gplusAccount = Repositories.GplusRepository.getGAAccount(profileId, _redisCache, dbr); if (gplusAccount == null) { return(BadRequest("Invalid ProfileId")); } if (gplusAccount.UserId != userId) { return(BadRequest("profile is added by other user")); } grpProfile.profileName = gplusAccount.GaProfileName; grpProfile.profileOwnerId = userId; grpProfile.profilePic = gplusAccount.ProfilePicUrl; } else if (profileType == Domain.Socioboard.Enum.SocialProfileType.Instagram) { Domain.Socioboard.Models.Instagramaccounts _Instagramaccounts = Repositories.InstagramRepository.getInstagramAccount(profileId, _redisCache, dbr); if (_Instagramaccounts == null) { return(BadRequest("Invalid ProfileId")); } if (_Instagramaccounts.UserId != userId) { return(BadRequest("profile is added by other user")); } grpProfile.profileName = _Instagramaccounts.InsUserName; grpProfile.profileOwnerId = userId; grpProfile.profilePic = _Instagramaccounts.ProfileUrl; } else if (profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedIn) { Domain.Socioboard.Models.LinkedInAccount _LinkedInAccount = Repositories.LinkedInAccountRepository.getLinkedInAccount(profileId, _redisCache, dbr); if (_LinkedInAccount == null) { return(BadRequest("Invalid ProfileId")); } if (_LinkedInAccount.UserId != userId) { return(BadRequest("profile is added by other user")); } grpProfile.profileName = _LinkedInAccount.LinkedinUserName; grpProfile.profileOwnerId = userId; grpProfile.profilePic = _LinkedInAccount.ProfileImageUrl; } else if (profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage) { Domain.Socioboard.Models.LinkedinCompanyPage _LinkedInAccount = Repositories.LinkedInAccountRepository.getLinkedinCompanyPage(profileId, _redisCache, dbr); if (_LinkedInAccount == null) { return(BadRequest("Invalid ProfileId")); } if (_LinkedInAccount.UserId != userId) { return(BadRequest("profile is added by other user")); } grpProfile.profileName = _LinkedInAccount.LinkedinPageName; grpProfile.profileOwnerId = userId; grpProfile.profilePic = _LinkedInAccount.LogoUrl; } else if (profileType == Domain.Socioboard.Enum.SocialProfileType.YouTube) { Domain.Socioboard.Models.YoutubeChannel _YoutubeChannel = Repositories.GplusRepository.getYTChannel(profileId, _redisCache, dbr); if (_YoutubeChannel == null) { return(BadRequest("Invalid ProfileId")); } if (_YoutubeChannel.UserId != userId) { return(BadRequest("profile is added by other user")); } grpProfile.profileName = _YoutubeChannel.YtubeChannelName; grpProfile.profileOwnerId = userId; grpProfile.profilePic = _YoutubeChannel.ChannelpicUrl; } if (profileType == Domain.Socioboard.Enum.SocialProfileType.Pinterest) { Domain.Socioboard.Models.PinterestAccount pinAcc = dbr.Find <Domain.Socioboard.Models.PinterestAccount>(t => t.username.Equals(profileId)).FirstOrDefault(); if (pinAcc == null) { return(BadRequest("Invalid profileId")); } if (pinAcc.userid != userId) { return(BadRequest("profile is added by other user")); } grpProfile.profileName = pinAcc.firstname + " " + pinAcc.lastname; grpProfile.profileOwnerId = userId; grpProfile.profilePic = pinAcc.profileimgaeurl; grpProfile.profileType = profileType; } grpProfile.entryDate = DateTime.UtcNow; grpProfile.groupId = grp.id; grpProfile.profileId = profileId; grpProfile.profileType = profileType; dbr.Add <Domain.Socioboard.Models.Groupprofiles>(grpProfile); //codes to clear cache _redisCache.Delete(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId); //end codes to clear cache return(Ok("Added Successfully")); } } }
public static List <Domain.Socioboard.Models.profilesdetail> getTop3GroupProfiles(long groupId, Helper.Cache _redisCache, Model.DatabaseRepository dbr) { //try //{ // List<Domain.Socioboard.Models.Groupprofiles> inMemGroupProfiles = _redisCache.Get<List<Domain.Socioboard.Models.Groupprofiles>>(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId); // if (inMemGroupProfiles != null) // { // return inMemGroupProfiles; // } //} //catch { } //Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail(); List <Domain.Socioboard.Models.profilesdetail> lstprofiledetail = new List <profilesdetail>(); List <Domain.Socioboard.Models.Groupprofiles> groupProfiles = dbr.FindWithRange <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId, 0, 3).ToList(); // _redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId, groupProfiles); // List<Domain.Socioboard.Models.Groupprofiles> groupProfiless = groupProfiles.Take(3).ToList(); foreach (Domain.Socioboard.Models.Groupprofiles profile in groupProfiles) { if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.Facebook) { Domain.Socioboard.Models.Facebookaccounts fbAcc = Repositories.FacebookRepository.getFacebookAccount(profile.profileId, _redisCache, dbr); Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail(); profiledetails.Fbaccount = fbAcc; lstprofiledetail.Add(profiledetails); } else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage) { Domain.Socioboard.Models.Facebookaccounts fbpageAcc = Repositories.FacebookRepository.getFacebookAccount(profile.profileId, _redisCache, dbr); Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail(); profiledetails.Fbaccount = fbpageAcc; lstprofiledetail.Add(profiledetails); } else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter) { Domain.Socioboard.Models.TwitterAccount twtAcc = Repositories.TwitterRepository.getTwitterAccount(profile.profileId, _redisCache, dbr); Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail(); profiledetails.Twtaccount = twtAcc; lstprofiledetail.Add(profiledetails); } else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.Instagram) { Domain.Socioboard.Models.Instagramaccounts insAcc = Repositories.InstagramRepository.getInstagramAccount(profile.profileId, _redisCache, dbr); Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail(); profiledetails.Instaaccount = insAcc; lstprofiledetail.Add(profiledetails); } else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.GPlus) { Domain.Socioboard.Models.Googleplusaccounts gPlusAcc = Repositories.GplusRepository.getGPlusAccount(profile.profileId, _redisCache, dbr); Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail(); profiledetails.Gplusaccount = gPlusAcc; lstprofiledetail.Add(profiledetails); } else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedIn) { Domain.Socioboard.Models.LinkedInAccount linkdAcc = Repositories.LinkedInAccountRepository.getLinkedInAccount(profile.profileId, _redisCache, dbr); Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail(); profiledetails.LinkdInaccount = linkdAcc; lstprofiledetail.Add(profiledetails); } else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage) { Domain.Socioboard.Models.LinkedinCompanyPage LinkedcompanyAcc = Repositories.LinkedInAccountRepository.getLinkedinCompanyPage(profile.profileId, _redisCache, dbr); Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail(); profiledetails.LinkdINcompanyaccount = LinkedcompanyAcc; lstprofiledetail.Add(profiledetails); } else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.YouTube) { Domain.Socioboard.Models.YoutubeChannel YTChnl = Repositories.GplusRepository.getYTChannel(profile.profileId, _redisCache, dbr); Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail(); profiledetails.Ytubeaccount = YTChnl; lstprofiledetail.Add(profiledetails); } else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.GoogleAnalytics) { Domain.Socioboard.Models.GoogleAnalyticsAccount gAAcc = Repositories.GplusRepository.getGAAccount(profile.profileId, _redisCache, dbr); Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail(); profiledetails.GAaccount = gAAcc; lstprofiledetail.Add(profiledetails); } else if (profile.profileType == Domain.Socioboard.Enum.SocialProfileType.Pinterest) { Domain.Socioboard.Models.PinterestAccount PinAcc = Repositories.PinterestRepository.getPinterestAccountDetail(profile.profileId, _redisCache, dbr); Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail(); profiledetails.Pintrestaccount = PinAcc; lstprofiledetail.Add(profiledetails); } //lstprofiledetail.Add(profiledetails); } return(lstprofiledetail); }
public static List <Domain.Socioboard.Models.profilesdetail> SearchProfileType(long groupId, string Profiletype, Helper.Cache _redisCache, Model.DatabaseRepository dbr) { try { List <Domain.Socioboard.Models.Groupprofiles> inMemGroupProfiles = _redisCache.Get <List <Domain.Socioboard.Models.Groupprofiles> >(Domain.Socioboard.Consatants.SocioboardConsts.CacheGroupProfiles + groupId); if (inMemGroupProfiles != null) { // return inMemGroupProfiles; } } catch { } List <Domain.Socioboard.Models.profilesdetail> lstprofiledetail = new List <profilesdetail>(); { if (Profiletype == "Facebook") { List <Domain.Socioboard.Models.Groupprofiles> FbProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.Facebook).ToList(); foreach (Domain.Socioboard.Models.Groupprofiles profil in FbProfiles) { Domain.Socioboard.Models.Facebookaccounts fbAcc = Repositories.FacebookRepository.getFacebookAccount(profil.profileId, _redisCache, dbr); Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail(); profiledetails.Fbaccount = fbAcc; lstprofiledetail.Add(profiledetails); } } else if (Profiletype == "FacebookPage") { List <Domain.Socioboard.Models.Groupprofiles> Fbpage = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage).ToList(); foreach (Domain.Socioboard.Models.Groupprofiles page in Fbpage) { Domain.Socioboard.Models.Facebookaccounts fbpageAcc = Repositories.FacebookRepository.getFacebookAccount(page.profileId, _redisCache, dbr); Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail(); profiledetails.Fbaccount = fbpageAcc; lstprofiledetail.Add(profiledetails); } } else if (Profiletype == "twitter") { List <Domain.Socioboard.Models.Groupprofiles> TwitterProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter).ToList(); foreach (Domain.Socioboard.Models.Groupprofiles Twitter in TwitterProfiles) { Domain.Socioboard.Models.TwitterAccount twtAcc = Repositories.TwitterRepository.getTwitterAccount(Twitter.profileId, _redisCache, dbr); Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail(); profiledetails.Twtaccount = twtAcc; lstprofiledetail.Add(profiledetails); } } else if (Profiletype == "instagram") { List <Domain.Socioboard.Models.Groupprofiles> InstagramProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.Instagram).ToList(); foreach (Domain.Socioboard.Models.Groupprofiles Instagram in InstagramProfiles) { Domain.Socioboard.Models.Instagramaccounts insAcc = Repositories.InstagramRepository.getInstagramAccount(Instagram.profileId, _redisCache, dbr); Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail(); profiledetails.Instaaccount = insAcc; lstprofiledetail.Add(profiledetails); } } else if (Profiletype == "googlepluse") { List <Domain.Socioboard.Models.Groupprofiles> GPlusProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.GPlus).ToList(); foreach (Domain.Socioboard.Models.Groupprofiles GPlus in GPlusProfiles) { Domain.Socioboard.Models.Googleplusaccounts gPlusAcc = Repositories.GplusRepository.getGPlusAccount(GPlus.profileId, _redisCache, dbr); Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail(); profiledetails.Gplusaccount = gPlusAcc; lstprofiledetail.Add(profiledetails); } } else if (Profiletype == "linkedin") { List <Domain.Socioboard.Models.Groupprofiles> LinkedInProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedIn).ToList(); foreach (Domain.Socioboard.Models.Groupprofiles LinkedIn in LinkedInProfiles) { Domain.Socioboard.Models.LinkedInAccount linkdAcc = Repositories.LinkedInAccountRepository.getLinkedInAccount(LinkedIn.profileId, _redisCache, dbr); Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail(); profiledetails.LinkdInaccount = linkdAcc; lstprofiledetail.Add(profiledetails); } } else if (Profiletype == "linkedincompanypage") { List <Domain.Socioboard.Models.Groupprofiles> LinkedInComapanyPageProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage).ToList(); foreach (Domain.Socioboard.Models.Groupprofiles LinkedInComapanyPage in LinkedInComapanyPageProfiles) { Domain.Socioboard.Models.LinkedinCompanyPage LinkedcompanyAcc = Repositories.LinkedInAccountRepository.getLinkedinCompanyPage(LinkedInComapanyPage.profileId, _redisCache, dbr); Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail(); profiledetails.LinkdINcompanyaccount = LinkedcompanyAcc; lstprofiledetail.Add(profiledetails); } } else if (Profiletype == "Youtube") { List <Domain.Socioboard.Models.Groupprofiles> YouTubeProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.YouTube).ToList(); foreach (Domain.Socioboard.Models.Groupprofiles YouTube in YouTubeProfiles) { Domain.Socioboard.Models.YoutubeChannel YTChnl = Repositories.GplusRepository.getYTChannel(YouTube.profileId, _redisCache, dbr); Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail(); profiledetails.Ytubeaccount = YTChnl; lstprofiledetail.Add(profiledetails); } } else if (Profiletype == "GAnalytics") { List <Domain.Socioboard.Models.Groupprofiles> GoogleAnalyticsProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.GoogleAnalytics).ToList(); foreach (Domain.Socioboard.Models.Groupprofiles GoogleAnalytics in GoogleAnalyticsProfiles) { Domain.Socioboard.Models.GoogleAnalyticsAccount gAAcc = Repositories.GplusRepository.getGAAccount(GoogleAnalytics.profileId, _redisCache, dbr); Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail(); profiledetails.GAaccount = gAAcc; lstprofiledetail.Add(profiledetails); } } else if (Profiletype == "Pinterest") { List <Domain.Socioboard.Models.Groupprofiles> PinterestProfiles = dbr.Find <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && t.profileType == Domain.Socioboard.Enum.SocialProfileType.Pinterest).ToList(); foreach (Domain.Socioboard.Models.Groupprofiles Pinterest in PinterestProfiles) { Domain.Socioboard.Models.PinterestAccount PinAcc = Repositories.PinterestRepository.getPinterestAccountDetail(Pinterest.profileId, _redisCache, dbr); Domain.Socioboard.Models.profilesdetail profiledetails = new profilesdetail(); profiledetails.Pintrestaccount = PinAcc; lstprofiledetail.Add(profiledetails); } } return(lstprofiledetail); } }