Beispiel #1
0
        public virtual ActionResult Today()
        {
            var model = new PhotoToday();

            model.Items = _itemBiz.GetList().Where(i => i.HasPhoto).OrderByDescending(i => i.PubDate).Take(12).ToList();

            return(View(model));
        }
Beispiel #2
0
        public virtual JsonResult ReadData([DataSourceRequest] DataSourceRequest request)
        {
            var query = _feedItemBusiness.GetList().OrderByDescending(item => item.CreateDate);

            var result = new DataSourceResult()
            {
                Data = query.Skip((request.Page - 1) * request.PageSize).Take(request.PageSize).ToList().Select(item => new FeedItem()
                {
                    CreateDate      = item.CreateDate,
                    Deleted         = item.Deleted,
                    FeedId          = item.FeedId,
                    Id              = item.Id,
                    Link            = item.Link,
                    PubDate         = item.PubDate,
                    ShowContentType = item.ShowContentType,
                    SiteTitle       = item.SiteTitle,
                    SiteUrl         = item.SiteUrl,
                    Title           = item.Title,
                    VisitsCount     = item.VisitsCount
                }).ToList(),
                Total = query.Count()
            };

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
        public virtual ActionResult Index(int page = 1)
        {
            var model = new DashboardModel();
            var today = DateTime.Today;

            model.SitesCount = _siteBusiness.GetList().Count();

            model.Feeds            = _feedBusiness.GetList().OrderByDescending(f => f.LastUpdateDateTime).Take(10).ToList();
            model.ActiveFeedsCount = _feedBusiness.GetList().Where(f => f.Deleted == Common.Share.DeleteStatus.Active).Count();
            model.TodayFeedsCount  = _feedBusiness.GetList().Where(f => f.LastUpdateDateTime >= today).Count();

            model.Comments   = _commentBiz.GetList().OrderByDescending(c => c.Id).Take(8).ToList();
            model.Posts      = _postBiz.GetList().Where(p => p.PostType == PostType.News).OrderByDescending(p => p.Id).Take(8).ToList();
            model.PostsCount = _postBiz.GetList().Count();

            model.UsersCount = _userBusiness.GetList().Count();
            model.Users      = _userBusiness.GetList().OrderByDescending(u => u.Id).Take(8).ToList();

            model.MessagesCount = _contactBusiness.GetList().Count();

            model.TodayItemsCount = _feedItemBusiness.GetList().Where(t => t.CreateDate >= today).Count();

            return(View(model));
        }
Beispiel #4
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));
        }