Ejemplo n.º 1
0
        public List <DtoNewsFeed> ExplorehNewsFeed(long UserID, string search, long PageNumber, long RowsPerPage)
        {
            try
            {
                var dalemotion = new DalEmotions();

                var lstdtonewsfeed    = new List <DtoNewsFeed>();
                var newlstdtonewsfeed = new List <DtoNewsFeed>();
                var lstemotion        = new List <DtoEmotions>();

                _daltag = new DalTag();

                lstdtonewsfeed = _daltag.ExplorehNewsFeed(UserID, search, PageNumber, RowsPerPage);

                if (lstdtonewsfeed != null)
                {
                    IEnumerable <long> query = (from ca in lstdtonewsfeed
                                                select ca.PremalinkId).Distinct();

                    if (query != null)
                    {
                        foreach (long item in query)
                        {
                            IEnumerable <long> uniquetagid = (from ca in lstdtonewsfeed
                                                              where ca.PremalinkId == item && ca.TagId != 0
                                                              select ca.TagId).Distinct();

                            IEnumerable <long> uniqueemoid = (from ca in lstdtonewsfeed
                                                              where ca.PremalinkId == item && ca.EmotionId != 0
                                                              select ca.EmotionId).Distinct();
                            string tagstr = "";
                            int    index  = 0;
                            foreach (int str in uniquetagid)
                            {
                                DtoNewsFeed dto = (from ca in lstdtonewsfeed
                                                   where ca.PremalinkId == item &&
                                                   ca.TagId == str
                                                   select ca).FirstOrDefault();

                                tagstr += "|" + dto.TagId + "," + dto.TagName + "," + dto.TotalVote + "," + dto.UpVote +
                                          "," +
                                          dto.DownVote + "," + dto.TaggedByUser + ",";
                                index += 1;

                                if (index == uniquetagid.Count())
                                {
                                    newlstdtonewsfeed.Add(new DtoNewsFeed
                                    {
                                        PremalinkId = dto.PremalinkId,
                                        Title       = dto.Title,
                                        Description = dto.Description,
                                        Image       = dto.Image,
                                        CreatedOn   = dto.CreatedOn,
                                        Tagstring   = tagstr,
                                        Link        = dto.Link,
                                        WebsiteName = dto.WebsiteName
                                    });
                                }
                            }

                            string emostr = "";
                            index = 0;

                            foreach (int str in uniqueemoid)
                            {
                                DtoNewsFeed dto = (from ca in lstdtonewsfeed
                                                   where ca.PremalinkId == item &&
                                                   ca.EmotionId == str
                                                   select ca).FirstOrDefault();
                                index  += 1;
                                emostr += "|" + dto.EmotionId + "," + dto.EmotionName + "," + dto.TotalCount + "," +
                                          dto.IsActive;

                                if (index == uniqueemoid.Count())
                                {
                                    DtoNewsFeed q = (from c in newlstdtonewsfeed
                                                     where c.PremalinkId == dto.PremalinkId
                                                     select c).FirstOrDefault();
                                    q.EmotionString = emostr;
                                    emostr          = "";
                                }
                            }
                        }
                    }
                }
                return(newlstdtonewsfeed);
            }
            catch (Exception ex)
            {
                ex.ToExceptionless().Submit();
            }
            return(null);
        }