Exemplo n.º 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 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));
        }
        public IActionResult getProfilesAvailableToConnect(long groupId, long userId)
        {
            var  dbr = new DatabaseRepository(_logger, _appEnv);
            var  lstGroupProfiles = GroupProfilesRepository.GetAllGroupProfiles(groupId, _redisCache, dbr);
            var  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)))));
        }
        public IActionResult GetAllYTChannelsSB(long groupId)
        {
            var dbr               = new DatabaseRepository(_logger, _appEnv);
            var lstGrpProfiles    = GroupProfilesRepository.GetAllGroupProfiles(groupId, _redisCache, dbr);
            var lstYoutubeChannel = new List <YoutubeChannel>();

            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);
                }
            }

            return(Ok(lstYoutubeChannel));
        }
        public IActionResult GetAllGroupProfiles(long groupId)
        {
            DatabaseRepository dbr = new DatabaseRepository(_logger, _appEnv);

            return(Ok(GroupProfilesRepository.GetAllGroupProfiles(groupId, _redisCache, dbr)));
        }