Example #1
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));
        }
Example #2
0
        public virtual ActionResult Index(string Content, int PageIndex)
        {
            var model           = new CatItemsPageModel();
            var LastItemPubDate = DateTime.Now.AddMinutes(10);
            var catCurrent      = _categoryBusiness.Get(Content);

            #region ViewBag
            ViewBag.EnTityRef      = catCurrent.Id;
            ViewBag.Toggle         = "1";
            ViewBag.SearchTextDir  = "text-align:right;direction:rtl;display:none";
            ViewBag.Title          = catCurrent.Title;
            ViewBag.ImageThumbnail = catCurrent.ImageThumbnail;
            ViewBag.Content        = catCurrent.Code.Trim().ToLower();
            ViewBag.PageHeader     = "اخبار " + catCurrent.Title;
            ViewBag.KeyWords       = string.IsNullOrEmpty(catCurrent.KeyWords) ? "" : catCurrent.KeyWords.Replace("-", ",");
            ViewBag.Discription    = catCurrent.Description;
            ViewBag.CatCurrent     = catCurrent;
            ViewBag.PageIndex      = PageIndex + 1;
            ViewBag.PageCount      = 15;
            #endregion

            var allcats = _categoryBusiness.GetList(catCurrent.Id).ToList();
            allcats.Insert(0, catCurrent);
            var Id = catCurrent.Id;
            model.Items       = _feedItemBusiness.FeedItemsByCat(Id, PageSize, PageIndex, false);
            model.VisualItems = _feedItemBusiness.FeedItemsByCat(Id, _appConfigBiz.GetVisualPostCount() + _appConfigBiz.GetVisualPostCount(), PageIndex, true);
            //-----------------Sub cat-------------------
            var SubCats = allcats.Where(x => x.ParentId == catCurrent.Id).ToList();
            SubCats.ForEach(x => x.ParentId = 0);
            if (SubCats.Count() > 0)
            {
                ViewBag.Categorys = SubCats;
                var items = new List <SelectListItem>();
                items.Add(new SelectListItem {
                    Text = "همه مطالب", Value = catCurrent.Code
                });
                foreach (var SubCat in SubCats)
                {
                    items.Add(new SelectListItem {
                        Text = SubCat.Title, Value = SubCat.Code
                    });
                }
                ViewBag.SubCats = items;
            }


            var allIds = allcats.Select(x => x.Id).ToList();
            ViewBag.RelatedTags = _tagBusiness.GetList()
                                  .Where(t => t.Categories.Any(tc => allIds.Contains(tc.Id))).ToList();
            //ViewBag.RelatedTags = context.Tags.Where(x => x.TagCategories.Where(c => c.Categorie_CatCurrent == ViewBag.CatCurrent.CatCurrent || c.Categorie_CatCurrent == ViewBag.CatCurrent.ParentId).Count() > 0).ToList();

            //----------------Top Site in this Cat-------
            ViewBag.TopSites = _unitOfWork.Database.SqlQueryCache_FirstParam <SiteOnlyTitle>(120, "Sites_Select_TopByCat {0},{1}", catCurrent.Id, 15).ToList();
            if (ViewBag.TopSites == null)
            {
                ViewBag.TopSites = _siteBusiness.GetTopSites(18, 120);
            }

            model.Posts = _postBiz.GetList().Where(p => !p.MetaData.IsDeleted && p.PublishDate < DateTime.Now && p.Categories.Any(pc => pc.Id == catCurrent.Id || pc.ParentId == catCurrent.Id))
                          .Take(_appConfigBiz.GetVisualPostCount()).ToList();

            #region Tabs
            //ViewBag.RemoteWebParts = (from p in Ioc.DataContext.RemoteWebParts
            //                          where
            //                          p.Active == true &&
            //                          p.Categories.Any(x => x.Id == catCurrent.Id)
            //                          select p).ToList();

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

            #endregion

            return(View("Index." + CmsConfig.ThemeName, model));
        }
Example #3
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));
        }