public virtual ActionResult MostVisitedItems(string EntityCode, int EntityRef, int PageSize) { PageSize = PageSize > 20 ? 20 : PageSize; var res = _feedItemBusiness.MostVisitedItems(EntityCode, EntityRef, PageSize, 30); ViewBag.PageHeader = "پر بیننده ترین های "; return(PartialView("_MostVisitedItems", res)); }
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)); }