Ejemplo n.º 1
0
        public List <FeedItem> Get(string content, int pageIndex, int pageSize)
        {
            if (content.Contains("."))
            {
                var site = _siteBusiness.Get(content);
                if (site != null)
                {
                    return(_feedItemBusiness.FeedItemsBySite(site.Id, pageSize, pageIndex).ToList());
                }
            }
            else
            {
                var cat = _categoryBusiness.Get(content);
                if (cat != null)
                {
                    return(_feedItemBusiness.FeedItemsByCat(cat.Id, pageSize, pageIndex).ToList());
                }

                var tag = _tagBusiness.Get(content);
                if (tag != null)
                {
                    return(_feedItemBusiness.FeedItemsByTag(tag, pageSize, pageIndex).ToList());
                }
                else
                {
                    return(_feedItemBusiness.FeedItemsByKey(content, pageSize, pageIndex).ToList());
                }
            }
            return(null);
        }
Ejemplo n.º 2
0
        public virtual ActionResult FeedItems(string Content, int PageIndex, string type = "cat")
        {
            if (PageIndex > 5)
            {
                PageIndex = 5;
            }

            ViewBag.Content = Content;
            string tagTitle = string.Empty;
            IEnumerable <FeedItem> res;

            if (type == "cat")
            {
                res = _feedItemBusiness.FeedItemsByCat(ref Content, 10, PageIndex);
            }
            else
            {
                res = _feedItemBusiness.FeedItemsByTag(Content, 10, PageIndex, ref tagTitle);
            }

            #region viewBag
            ViewBag.Type       = type;
            ViewBag.PageIndex  = PageIndex + 1;
            ViewBag.PageHeader = "تازه ترین های " + Content;
            #endregion

            return(PartialView("_MoreItems", res));
        }
Ejemplo n.º 3
0
        public virtual ActionResult Index(string Content, int PageSize)
        {
            var cat = _categoryBusiness.Get(Content);

            if (cat != null)
            {
                var allcats = _categoryBusiness.GetList(cat.Id).ToList();
                allcats.Insert(0, cat);
                var res = _feedItemBusiness.FeedItemsByCat(cat.Id, PageSize, 0);
                return(new FeedResult("تازه ترین مطالب پیرامون  " + cat.Title, res.ToList()));
            }
            var tag = _tagBusiness.Get(Content);

            if (tag != null)
            {
                var res = _feedItemBusiness.FeedItemsByTag(tag, PageSize, 0);
                return(new FeedResult("تازه ترین مطالب پیرامون  " + tag.Title, res.ToList()));
            }
            return(View());
        }
Ejemplo n.º 4
0
        [OutputCache(Duration = CmsConfig.Cache5Min, VaryByParam = "Content;PageIndex")]//, VaryByCustom = "IsMobile"
        public virtual ActionResult Index(string content, int PageIndex = 0)
        {
            var model = new TagItemsPageModel();

            content = content.Replace("_", " ");
            content = content.Replace("+", " ");
            var TagCurrent      = new Tag();
            var LastItemPubDate = DateTime.Now.AddMinutes(15);

            //if (Content.EqualsX("All") || string.IsNullOrEmpty(Content))
            //    return RedirectToAction(MVC.Tag.Actions.ActionNames.All, MVC.Tag.Name);

            try
            {
                TagCurrent = _unitOfWork.Set <Tag>().SingleOrDefault(x => x.Title.Equals(content) || x.EnValue == content);
                //    if (TagCurrent.Value.Trim().Length != Content.Trim().Length && TagCurrent.EnValue.Trim().Length != Content.Trim().Length)
                //        return RedirectToAction(MVC.Key.ActionNames.Index, MVC.Key.Name, new { Content = Content, PageSize = PageSize, LastItemPubDate });
            }
            catch
            {
                var tagCurrents = _unitOfWork.Set <Tag>().Where(x => x.Value.StartsWith(content));
                if (tagCurrents.Any())
                {
                    TagCurrent = tagCurrents.First();
                }
                else
                {
                    return(RedirectToAction(MVC.Key.ActionNames.Index, MVC.Key.Name, new { Content = content, PageSize = PageSize, LastItemPubDate }));
                }
            }
            if (TagCurrent == null)
            {
                return(RedirectToAction(MVC.Key.ActionNames.Index, MVC.Key.Name, new { Content = content, PageSize = PageSize, LastItemPubDate }));
            }


            #region ViewBag
            //ViewBag.EntityCode = "Tag";
            ViewBag.EntityRef = TagCurrent.Id;
            //ViewBag.PageSize = PageSize;
            ViewBag.Toggle             = "1";
            ViewBag.SearchTextDir      = "text-align:right;direction:rtl";
            ViewBag.Title              = "اخبار " + TagCurrent.Title;
            ViewBag.ImageThumbnail     = TagCurrent.ImageThumbnail;
            ViewBag.HasBackgroundImage = TagCurrent.HasBackgroundImage;
            ViewBag.Content            = string.IsNullOrEmpty(TagCurrent.EnValue) ? TagCurrent.Value.Trim() : TagCurrent.EnValue;
            ViewBag.SearchExpersion    = "Tag:" + TagCurrent.Value;
            ViewBag.PageHeader         = "تازه ترین های " + TagCurrent.Title;
            ViewBag.Discription        = "تازه ترین های اخبار روز و مطالب " + TagCurrent.Title;
            ViewBag.KeyWords           = "," + TagCurrent.EnValue + "," + TagCurrent.Value.Replace("|", ",") + ",اخبار روز,تازه ترین خبرها,خبرخوان";
            ViewBag.TagCurrent         = TagCurrent;
            ViewBag.PageIndex          = PageIndex + 1;
            #endregion
            if (string.IsNullOrEmpty(TagCurrent.Value) && string.IsNullOrEmpty(TagCurrent.EnValue))
            {
                return(RedirectToAction(MVC.Tag.Name, MVC.Tag.ActionNames.All, null));
            }

            #region Body

            model.Items       = _feedItemBusiness.FeedItemsByTag(TagCurrent, PageSize, PageIndex);
            model.VisualItems = _feedItemBusiness.FeedItemsByTag(TagCurrent, _appConfigBiz.GetVisualPostCount() + _appConfigBiz.GetVisualPostCount(), PageIndex, true);
            model.Posts       = _postBiz.GetList().Where(p => !p.MetaData.IsDeleted && p.PublishDate < DateTime.Now && p.Tags.Any(tc => tc.Id == TagCurrent.Id || tc.ParentTagId == TagCurrent.Id))
                                .Take(_appConfigBiz.GetVisualPostCount()).ToList();
            #endregion
            #region SitesTags
            //----------------Top Site in this Tag-------
            var cats = TagCurrent.Categories.ToList();
            try
            {
                if (cats.Any())
                {
                    var catsid = cats.Select(x => x.Id).ToList();
                    var feeds  = _feedBusiness.GetList().Where(f => f.Categories.Any(cf => catsid.Contains(cf.Id)));
                    var sites  = feeds.Select(f => f.Site);
                    ViewBag.TopSites = sites.Distinct().Select(s => new SiteOnlyTitle()
                    {
                        SiteTitle = s.SiteTitle, SiteUrl = s.SiteUrl
                    }).Take(20).ToList();
                }
                //ViewBag.TopSites = context.Database.SqlQuery<SiteOnlyTitle>("Sites_Select_TopByTag {0},{1}", TagCurrent.TagId, 15).ToList();
            }
            catch { }

            var relatedTags = cats.SelectMany(c => c.Tags.Select(t => t)).Distinct().Take(25).ToList();
            //relatedTags.Remove(TagCurrent.Id);
            ViewBag.RelatedTags = relatedTags;

            #endregion
            //B_feeditem.IncreaseVisitCount(res as IEnumerable<FeedItem>);
            model.Items = _feedItemBusiness.DescriptClear(model.Items, TagCurrent.Value).ToList();
            //_feedItemBusiness.Add_FeedItemtoCache(content, PageIndex, View(res), 60);

            #region Tabs
            //var webParts = Ioc.RemoteWpBiz.GetByTag(TagCurrent.Id).ToList();
            //if (webParts.Any())
            //    ViewBag.RemoteWebParts = webParts;
            //else
            //    if (TagCurrent.Categories.Any())
            //    ViewBag.RemoteWebParts = Ioc.RemoteWpBiz.GetByCats(TagCurrent.Categories.Select(c => c.Id).ToList()).ToList();

            //ViewBag.Pages = TagCurrent.Posts.Where(p => p.PostType == PostType.Tab).ToList();

            #endregion
            return(View("Index." + CmsConfig.ThemeName, model));
        }