Ejemplo n.º 1
0
        public static List <Domain.Socioboard.Models.Mongo.AdvanceSerachData> GetSortBy(string sortBy, Helper.Cache _redisCache, Helper.AppSettings settings)
        {
            MongoRepository _RssRepository = new MongoRepository("AdvanceSerachData", settings);

            var builder = Builders <AdvanceSerachData> .Sort;
            var sort    = builder.Descending(t => t.postedTime);

            //var result = _RssRepository.FindWithRange<AdvanceSerachData>(t => t.totalShareCount != 0, sort, 0, 150);
            var result = _RssRepository.FindAdvance <AdvanceSerachData>(t => t.totalShareCount != 0);
            var task   = Task.Run(async() =>
            {
                return(await result);
            });
            IList <AdvanceSerachData> lsttwt = task.Result.ToList();

            lsttwt = lsttwt.OrderByDescending(kt => kt.postedTime).ToList();
            // lsttwt = lsttwt.OrderByDescending(gb => gb.totalShareCount).ToList().Take(30).Skip(0).ToList();
            //if (lsttwt != null)
            //{
            //    //_redisCache.Set(Domain.Socioboard.Consatants.SocioboardConsts.CacheTwitterRecent100Feeds + profileId, lstFbFeeds.ToList());

            //    return lsttwt.ToList();
            //}



            if (sortBy == "trending")
            {
                //return lsttwt.ToList();
                //  lsttwt.OrderByDescending(t => t.totalShareCount);
                return(lsttwt.OrderByDescending(t => t.totalShareCount).ToList());
            }
            if (sortBy == "mostshare")
            {
                return(lsttwt.OrderByDescending(t => t.totalShareCount).ToList());
            }
            else if (sortBy == "twtshare")
            {
                lsttwt.OrderByDescending(t => t.twtShareCount);
                return(lsttwt.OrderByDescending(t => t.twtShareCount).ToList());
            }
            else if (sortBy == "fbshare")
            {
                return(lsttwt.OrderByDescending(t => t.fbengagementCount).ToList());
            }
            else if (sortBy == "gplus")
            {
                return(lsttwt.OrderByDescending(t => t.gplusShareCount).ToList());
            }
            else if (sortBy == "Pininterest")
            {
                return(lsttwt.OrderByDescending(t => t.pinShareCount).ToList());
            }
            else if (sortBy == "LinkedIn")
            {
                return(lsttwt.OrderByDescending(t => t.linShareCount).ToList());
            }
            else if (sortBy == "redit")
            {
                return(lsttwt.OrderByDescending(t => t.redditShareCount).ToList());
            }
            else
            {
                return(null);
            }

            //return null;
        }