示例#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 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());
        }
示例#3
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));
        }
示例#4
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));
        }
示例#5
0
        public virtual ActionResult Index()
        {
            var Model = new HomeViewModel();

            #region colors
            Model.Colors = new List <string> {
                "rgba(8, 134, 190, 0.8)", "rgba(130, 181, 71, 0.8)", "rgba(120, 66, 147, 0.8) ", "rgba(255, 0, 57, 0.8)", "rgba(255, 117, 24, 0.8)", "rgba(39, 128, 227, 0.8)", "rgba(20, 156, 130, 0.8)", "rgba(153, 84, 187, 0.8)"
            };
            Model.Colors.Reverse();
            Model.Colors.AddRange(Model.Colors);
            Model.Colors.Reverse();
            Model.Colors.AddRange(Model.Colors);
            #endregion
            #region ViewBag
            ViewBag.Title        = "رسانه خبری";
            ViewBag.Description  = "تازه ترین و جدیدترین اخبار و فایل های صوتی و تصویری";
            ViewBag.KeyWords     = @"اخبار روز, اخبار ورزشی ,جدیدترین رادیوها,دانلود سخنرانی, خبرخوان,موتور جستجو,نرم افزار موبایل,farsi media";
            ViewBag.EntityCode   = "Home";
            ViewBag.EntityRef    = 0;
            ViewBag.defaultIndex = 1;

            #endregion
            #region Top Tags
            var itags = HttpContext.Cache.Get("IndexTags");
            if (itags != null)
            {
                Model.TopTags = HttpContext.Cache.Get("IndexTags") as List <Tag>;
            }
            else
            {
                Model.TopTags = _tagBusiness.GetList().Where(t => t.InIndex && !string.IsNullOrEmpty(t.ImageThumbnail)).Shuffle().Take(40).ToList();
                HttpContext.Cache.AddToCache("IndexTags", Model.TopTags, 40);
            }
            #endregion
            #region Items
            var cats = _categoryBusiness.GetList()
                       .Where(x => x.ViewMode == Common.Share.ViewMode.Index || x.ViewMode == Common.Share.ViewMode.MenuIndex)
                       .OrderByDescending(x => x.Priority).ToList();

            foreach (var cat in cats.Take(8))
            {
                var sliderModel = new SliderModel()
                {
                    Code = cat.Code
                };
                if (_appConfigBiz.GetConfig <bool>(Constants.EnabledOptions.IndexPhotoHeadlines))
                {
                    sliderModel.Items = _feedItemBusiness.GetList().Where(i => i.Feed.Categories.Any(c => (c.Id == cat.Id || c.ParentId == cat.Id) && i.HasPhoto))
                                        .OrderByDescending(i => i.PubDate).Take(4).ToList().Select(i => new SliderItemModel()
                    {
                        Description = i.Description,
                        Link        = string.Concat("/site/", i.SiteUrl, "/", i.ItemId, "/", i.Title.RemoveBadCharacterInURL()),
                        ImageURL    = string.Concat("/", _appConfigBiz.VisualItemsPathVirtual().ToLower(), "/", i.Id, ".jpg"),
                        PubDate     = i.PubDate.Value,
                        Title       = i.Title,
                        VisitsCount = i.VisitsCount,
                        Refrence    = i.SiteTitle
                    }).ToList();
                }

                var res = _feedItemBusiness.FeedItemsByCat(cat.Id, 12, 0, 10).ToList();

                Model.CatItems.Add(new HomeItemsPanelViewModel()
                {
                    ShowMoreBtn = true, Cat = cat, Items = res.ToList(), slider = sliderModel
                });
            }
            Model.Categories = _categoryBusiness.GetList().Where(x => x.ViewMode != Common.Share.ViewMode.NotShow).ToList();
            #endregion
            #region Post
            //Model.Posts = _postBiz.GetList().Where(p => p.PostType == PostType.News && !p.MetaData.IsDeleted && p.PublishDate <= DateTime.Now)
            //    .Select(p => new PostModel()
            //    {
            //        Id = p.Id,
            //        Title = p.Title,
            //        SubTitle = p.SubTitle,
            //        PublishDate = p.PublishDate,
            //        PostImage = p.PostImage,
            //        VisitCount = p.VisitCount,
            //        LikeCount = p.LikeCount,
            //        DislikeCount = p.DislikeCount,
            //    }).Take(Ioc.AppConfigBiz.GetConfig<int>(Constants.Home.VisualPostCount)).ToList();

            //Model.Videos = _postBiz.GetList().Where(p => p.PostType == PostType.Video && !p.MetaData.IsDeleted && p.PublishDate <= DateTime.Now)
            //   .Select(p => new PostModel()
            //   {
            //       Id = p.Id,
            //       Title = p.Title,
            //       SubTitle = p.SubTitle,
            //       PublishDate = p.PublishDate,
            //       PostImage = p.PostImage,
            //       VisitCount = p.VisitCount,
            //       LikeCount = p.LikeCount,
            //       DislikeCount = p.DislikeCount,
            //   }).Take(Ioc.AppConfigBiz.GetConfig<int>(Constants.Home.VisualPostCount)).ToList();
            #endregion
            #region MostVisited
            var mosteItems = _feedItemBusiness.MostVisitedItems("today", 10, 15, 10).ToList();
            // if (mosteItems != null && mosteItems.Any())
            Model.MostVisitedItems = new HomeItemsPanelViewModel()
            {
                Items = mosteItems.ToList(),
                Cat   = new Category()
                {
                    Code = "news", Title = "پربازدیدترین ها", Color = Model.Colors[2]
                },
                // CssClass = "col-md-4",
                ShowMoreBtn = false
            };
            #endregion
            #region Top Site
            Model.TopSites = _siteBusiness.GetTopSites(20, 120);
            #endregion

            return(View("Index." + CmsConfig.ThemeName, Model));
        }