Beispiel #1
0
        public IActionResult GetUserGroupData(long userId, string groupId)
        {
            var dbr = new DatabaseRepository(_logger, _appEnv);

            var _GetUserGroupData = new GetUserGroupData();

            var lstgroup = new List <Groups>();

            var lstgrpmember = new List <Groupmembers>();

            lstgrpmember = dbr.Find <Groupmembers>(t => t.userId == userId && t.memberStatus == Domain.Socioboard.Enum.GroupMemberStatus.Accepted).ToList();

            var lstgrpId = lstgrpmember.Select(t => t.groupid).ToArray();

            lstgroup = dbr.Find <Groups>(t => lstgrpId.Contains(t.id)).ToList();

            var lstgrpProfiles = new List <Groupprofiles>();

            if (string.IsNullOrEmpty(groupId))
            {
                var lstStr = lstgroup.Select(t => t.id).ToArray();
                lstgrpProfiles = GroupProfilesRepository.GetAllGroupProfiles(lstStr[0], _redisCache, dbr);
            }
            else
            {
                lstgrpProfiles = GroupProfilesRepository.GetAllGroupProfiles(Convert.ToInt32(groupId), _redisCache, dbr);
            }

            var myProfiles = lstgrpProfiles.GroupBy(o => o.groupId).ToDictionary(g => g.Key, g => g.ToList());

            _GetUserGroupData.lstgroup   = lstgroup;
            _GetUserGroupData.myProfiles = myProfiles;
            return(Ok(_GetUserGroupData));
        }
        public IActionResult GetYTChannelsSB(long groupId)
        {
            var lstYoutubeChannel = new List <YoutubeChannel>();

            try
            {
                var dbr            = new DatabaseRepository(_logger, _appEnv);
                var lstGrpProfiles = GroupProfilesRepository.getGroupProfiles(groupId, _redisCache, dbr);

                foreach (var item in lstGrpProfiles.Where(t => t.profileType == SocialProfileType.YouTube))
                {
                    var YTChnl = GplusRepository.getYTChannel(item.profileId, _redisCache, dbr);
                    if (YTChnl != null)
                    {
                        lstYoutubeChannel.Add(YTChnl);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(Ok(lstYoutubeChannel));
        }
 public IActionResult GetYoutubeAccount(string code, long groupId, long userId)
 {
     try
     {
         var lstYoutubeProfiles = new List <YoutubeProfiles>();
         var dbr = new DatabaseRepository(_logger, _appEnv);
         lstYoutubeProfiles = GoogleHelper.GetYoutubeAccount(code, _appSettings, dbr);
         var lstGrpProfiles = GroupProfilesRepository.GetAllGroupProfiles(groupId, _redisCache, dbr);
         lstGrpProfiles = lstGrpProfiles.Where(t => t.profileType == SocialProfileType.YouTube).ToList();
         var lstStr = lstGrpProfiles.Select(t => t.profileId).ToArray();
         if (lstStr.Length > 0)
         {
             lstYoutubeProfiles.Where(t => lstStr.Contains(t.YtChannelId)).Select(s =>
             {
                 s.connected = 1;
                 return(s);
             }).ToList();
         }
         return(Ok(lstYoutubeProfiles));
     }
     catch (Exception ex)
     {
         _logger.LogError("GetGetYoutubeAccount" + ex.StackTrace);
         _logger.LogError("GetGetYoutubeAccount" + ex.Message);
         return(Ok(new List <YoutubeProfiles>()));
     }
 }
        public IActionResult GetAllGAProfiles(long groupId)
        {
            var lstGoogleAnalyticsAccount = new List <GoogleAnalyticsAccount>();

            try
            {
                var dbr            = new DatabaseRepository(_logger, _appEnv);
                var lstGrpProfiles = GroupProfilesRepository.GetAllGroupProfiles(groupId, _redisCache, dbr);

                foreach (var item in lstGrpProfiles.Where(t => t.profileType == SocialProfileType.GoogleAnalytics))
                {
                    var gAAcc = GplusRepository.getGAAccount(item.profileId, _redisCache, dbr);
                    if (gAAcc != null)
                    {
                        lstGoogleAnalyticsAccount.Add(gAAcc);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(Ok(lstGoogleAnalyticsAccount));
        }
        public IActionResult GetGplusProfilesOnly(long groupId)
        {
            var lstGplusAcc = new List <Googleplusaccounts>();

            try
            {
                var dbr = new DatabaseRepository(_logger, _appEnv);

                var lstGrpProfiles = GroupProfilesRepository.GetAllGroupProfiles(groupId, _redisCache, dbr)
                                     .Where(t => t.profileType == SocialProfileType.GPlus);

                lstGplusAcc.AddRange(
                    from item in lstGrpProfiles
                    select GplusRepository.getGPlusAccount(item.profileId, _redisCache, dbr)
                    into gPlusAcc
                    let userdata = dbr.Single <User>(t => t.Id == gPlusAcc.UserId)
                                   where gPlusAcc != null && userdata.EmailId != gPlusAcc.EmailId
                                   select gPlusAcc);

                return(Ok(lstGplusAcc));
            }
            catch (Exception)
            {
                return(Ok(lstGplusAcc));
            }
        }
        public IActionResult GetPrimaryGoogleAcc(long userId, long groupId)
        {
            var userGplusAcc = new Googleplusaccounts();

            try
            {
                var dbr            = new DatabaseRepository(_logger, _appEnv);
                var lstGrpProfiles = GroupProfilesRepository.GetAllGroupProfiles(groupId, _redisCache, dbr);

                lstGrpProfiles = lstGrpProfiles.Where(t => t.profileType == SocialProfileType.GPlus).ToList();
                foreach (var item in lstGrpProfiles)
                {
                    var gPlusAcc = GplusRepository.getGPlusAccount(item.profileId, _redisCache, dbr);
                    var userdata = dbr.Single <User>(t => t.Id == gPlusAcc.UserId);
                    if (gPlusAcc != null && userdata.EmailId == gPlusAcc.EmailId)
                    {
                        userGplusAcc = gPlusAcc;
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }

            return(Ok(userGplusAcc));
        }
Beispiel #7
0
        public IActionResult getProfilesAvailableToConnect(long groupId, long userId)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);
            List <Domain.Socioboard.Models.Groupprofiles> lstGroupProfiles = GroupProfilesRepository.getAllGroupProfiles(groupId, _redisCache, dbr);
            List <Domain.Socioboard.Models.Groups>        lstGroups        = GroupsRepository.getAllGroupsofUser(userId, _redisCache, dbr);
            long defaultGroupId = lstGroups.FirstOrDefault(t => t.groupName.Equals(Domain.Socioboard.Consatants.SocioboardConsts.DefaultGroupName)).id;
            List <Domain.Socioboard.Models.Groupprofiles> defalutGroupProfiles = GroupProfilesRepository.getAllGroupProfiles(defaultGroupId, _redisCache, dbr);

            return(Ok(defalutGroupProfiles.Where(t => !lstGroupProfiles.Any(x => x.profileId.Equals(t.profileId)))));
        }
Beispiel #8
0
        public IActionResult AddSelectedProfiles(long groupId, long userId)
        {
            string selectedProfiles = Request.Form["selectedProfiles"];

            string[]           Profiles = selectedProfiles.Split(',');
            DatabaseRepository dbr      = new DatabaseRepository(_logger, _appEnv);
            List <Domain.Socioboard.Models.Groupprofiles> lstGrpProfiles = Repositories.GroupProfilesRepository.getAllGroupProfiles(groupId, _redisCache, dbr);

            lstGrpProfiles = lstGrpProfiles.Where(t => !Profiles.Contains(t.profileId)).ToList();
            foreach (var item in lstGrpProfiles)
            {
                GroupProfilesRepository.DeleteProfile(groupId, userId, item.profileId, _redisCache, dbr, _appSettings);
            }
            return(Ok());
        }
Beispiel #9
0
        public IActionResult DeleteProfile(long groupId, long userId, string profileId)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);

            Domain.Socioboard.Models.Facebookaccounts fbAcc = dbr.Find <Domain.Socioboard.Models.Facebookaccounts>(t => t.FbUserId.Equals(profileId) && t.UserId == userId && t.IsActive).FirstOrDefault();
            // Domain.Socioboard.Models.User user = dbr.Find<Domain.Socioboard.Models.User>(t => t.Id.Equals(userId) && t.EmailId == fbAcc.EmailId && t.EmailValidateToken == "Facebook").FirstOrDefault();
            Domain.Socioboard.Models.User user = dbr.Find <Domain.Socioboard.Models.User>(t => t.Id.Equals(userId)).FirstOrDefault();
            if (fbAcc != null && fbAcc.EmailId == user.EmailId)
            {
                return(BadRequest("Primary Account can't be delete "));
            }
            else
            {
                return(Ok(GroupProfilesRepository.DeleteProfile(groupId, userId, profileId, _redisCache, dbr, _appSettings)));
            }
        }
Beispiel #10
0
        public IActionResult AddSelectedProfilesForBasicPlan(long groupId, long userId)
        {
            string selectedProfiles = Request.Form["selectedProfiles"];

            string[]           Profiles = selectedProfiles.Split(',');
            DatabaseRepository dbr      = new DatabaseRepository(_logger, _appEnv);
            //User user = dbr.Single<User>(t => t.Id == userId);
            //Domain.Socioboard.Enum.SBAccountType accounttype = user.AccountType;
            List <Domain.Socioboard.Models.Groupprofiles> lstGrpProfiles = Repositories.GroupProfilesRepository.getAllGroupProfiles(groupId, _redisCache, dbr);
            long FBProfiles       = dbr.GetCount <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && (t.profileType == Domain.Socioboard.Enum.SocialProfileType.Facebook || t.profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage || t.profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookPublicPage));
            long TwtProfiles      = dbr.GetCount <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && (t.profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter));
            long GplusProfiles    = dbr.GetCount <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && (t.profileType == Domain.Socioboard.Enum.SocialProfileType.GPlus && t.profileType == Domain.Socioboard.Enum.SocialProfileType.GplusPage));
            long LinkedInProfiles = dbr.GetCount <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && (t.profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedIn && t.profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage));
            long InstaProfiles    = dbr.GetCount <Domain.Socioboard.Models.Groupprofiles>(t => t.groupId == groupId && (t.profileType == Domain.Socioboard.Enum.SocialProfileType.Instagram));

            lstGrpProfiles = lstGrpProfiles.Where(t => !Profiles.Contains(t.profileId)).ToList();
            long lstFBProfile       = lstGrpProfiles.Where(t => !Profiles.Contains(t.profileId) && (t.profileType == Domain.Socioboard.Enum.SocialProfileType.Facebook || t.profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookFanPage || t.profileType == Domain.Socioboard.Enum.SocialProfileType.FacebookPublicPage)).Count();
            long lstTwtProfile      = lstGrpProfiles.Where(t => !Profiles.Contains(t.profileId) && t.profileType == Domain.Socioboard.Enum.SocialProfileType.Twitter).Count();
            long lstInstaProfile    = lstGrpProfiles.Where(t => !Profiles.Contains(t.profileId) && t.profileType == Domain.Socioboard.Enum.SocialProfileType.Instagram).Count();
            long lstLinkedInProfile = lstGrpProfiles.Where(t => !Profiles.Contains(t.profileId) && (t.profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedIn || t.profileType == Domain.Socioboard.Enum.SocialProfileType.LinkedInComapanyPage)).Count();
            long lstGplusProfile    = lstGrpProfiles.Where(t => !Profiles.Contains(t.profileId) && (t.profileType == Domain.Socioboard.Enum.SocialProfileType.GPlus || t.profileType == Domain.Socioboard.Enum.SocialProfileType.GplusPage)).Count();

            long FbCount       = FBProfiles - lstFBProfile;
            long twtCount      = TwtProfiles - lstTwtProfile;
            long InstaCount    = InstaProfiles - lstInstaProfile;
            long LinkedInCount = LinkedInProfiles - lstLinkedInProfile;
            long GplusCount    = GplusProfiles - lstGplusProfile;

            if (FbCount > 1 || twtCount > 1 || InstaCount > 1 || LinkedInCount > 1 || GplusCount > 1)
            {
                return(BadRequest("As per your plan you can use only one profile per network.Please choose profiles as per your plan"));
            }
            else
            {
                foreach (var item in lstGrpProfiles)
                {
                    GroupProfilesRepository.DeleteProfile(groupId, userId, item.profileId, _redisCache, dbr, _appSettings);
                }
                return(Ok());
            }
            //return Ok();
        }
        public IActionResult SearchProfile(long groupId, string Profiletype)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);

            return(Ok(GroupProfilesRepository.SearchProfileType(groupId, Profiletype, _redisCache, dbr)));
        }
Beispiel #12
0
        public IActionResult DeleteProfile(long groupId, long userId, string profileId)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);

            return(Ok(GroupProfilesRepository.DeleteProfile(groupId, userId, profileId, _redisCache, dbr, _appSettings)));
        }
Beispiel #13
0
        public IActionResult GetAllGroupProfilesDeatails(long groupId)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);

            return(Ok(GroupProfilesRepository.getAllGroupProfilesdetail(groupId, _redisCache, dbr)));
        }
Beispiel #14
0
        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 IActionResult GetTop3GroupProfiles(long groupId)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);

            return(Ok(GroupProfilesRepository.GetTop3GroupProfiles(groupId, _redisCache, dbr)));
        }
        public IActionResult GetUserProfileCount(long userId)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);

            return(Ok(GroupProfilesRepository.getAllProfilesCountOfUser(userId, _redisCache, dbr)));
        }
        public IActionResult IsPrimaryAcc(long userId, string profileId)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);

            return(Ok(GroupProfilesRepository.IsPrimaryAccount(userId, profileId, dbr, _appSettings)));
        }