예제 #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);
        }
예제 #2
0
        public virtual ActionResult Index(string Content, int PageIndex)
        {
            Content = Content.ReplaceX("www.", "");
            var siteCurrents = _siteBusiness.GetList(Content);

            if (siteCurrents.Count() == 0)
            {
                var startw = Content.Remove(Content.LastIndexOf(".") + 1, Content.Length - Content.LastIndexOf(".") - 1);
                siteCurrents = _siteBusiness.GetList(startw);
                if (!siteCurrents.Any())
                {
                    return(RedirectToAction(MVC.Error.notfound()));
                }
            }
            var siteCurrent = siteCurrents.First();

            #region ViewBag
            //ViewBag.EntityCode = "Site";
            ViewBag.EnTityRef = siteCurrent.Id;

            ViewBag.Title   = siteCurrent.SiteTitle + " " + siteCurrent.SiteUrl;
            ViewBag.Content = siteCurrent.SiteUrl;
            //ViewBag.KeyWords = siteCurrent.SiteTags;
            //ViewBag.PageSize = PageSize;
            ViewBag.SearchTextDir = "text-align:left;direction:ltr";
            ViewBag.siteCurrent   = siteCurrent;
            ViewBag.PageHeader    = "تازه ترین های " + siteCurrent.SiteTitle + " (" + siteCurrent.SiteUrl + ")";
            ViewBag.PageIndex     = PageIndex + 1;
            ViewBag.KeyWords      = "," + siteCurrent.SiteUrl + "," + siteCurrent.SiteTitle + ",اخبار روز,تازه ترین خبرها,خبرخوان";
            ViewBag.Discription   = "تازه ترین مطالب سایت " + siteCurrent.SiteTitle + " - " + siteCurrent.SiteUrl + " - " + siteCurrent.SiteDesc;
            #endregion
            var LastItemPubDate = DateTime.Now.AddMinutes(-15);
            var res             = _feedItemBusiness.FeedItemsBySite(siteCurrent.Id, PageSize, PageIndex, false);

            if (res.Count == 0)
            {
                res = _feedItemBusiness.FeedItemsByCat(6, PageSize, PageIndex, false);
            }

            if (siteCurrent.HasImage != HasImage.NotSupport)
            {
                ViewBag.VisualItems = _feedItemBusiness.FeedItemsBySite(siteCurrent.Id, _appConfigBiz.GetVisualPostCount() + _appConfigBiz.GetVisualPostCount(), PageIndex, true);
            }

            #region Related Site
            //----------------Related Site by this site-------
            ViewBag.TopSites = siteCurrent.Feeds.SelectMany(f => f.Categories)
                               .SelectMany(cf => cf.Feeds).Select(f2 => f2.Site).Take(20).ToList()
                               .Select(s => new SiteOnlyTitle()
            {
                SiteUrl = s.SiteUrl, SiteTitle = s.SiteTitle
            }).DistinctBy(x => x.SiteUrl).ToList();
            #endregion
            if (!(ViewBag.TopSites as List <SiteOnlyTitle>).Any())
            {
                ViewBag.TopSites = _siteBusiness.GetTopSites(15, 120);
            }
            #region Tabs
            //var cats = siteCurrent.Feeds.SelectMany(f => f.Categories.Select(cf => cf.Id)).ToList();
            //ViewBag.RemoteWebParts = Ioc.RemoteWpBiz.GetByCats(cats).ToList();
            //ViewBag.Pages = _postBiz.GetList().Where(p => p.PostType == PostType.Tab && p.Categories.Any(pc => cats.Contains(pc.Id))).ToList();
            #endregion
            return(View("Index." + CmsConfig.ThemeName, res));
        }