Exemplo n.º 1
0
        public ActionResult Index(NewsCondition condition)
        {
            var news   = service.SearchNews(condition);
            var models = new PagedList <NewsInfo>(news, news.Paging);

            return(View(PluginHelper.GetViewPath(this.GetType(), "Index"), models));
        }
Exemplo n.º 2
0
        public IPagedList <ImportantNewsInfo> SearchNews(NewsCondition condition)
        {
            var query = repository.Table;

            if (!string.IsNullOrEmpty(condition.Title))
            {
                query = query.Where(t => t.Title.Contains(condition.Title));
            }
            if (condition.NewsType != null)
            {
                query = query.Where(t => t.NewsType == condition.NewsType);
            }
            if (condition.BeginDate != null)
            {
                query = query.Where(t => t.ReleaseTime > condition.BeginDate);
            }
            if (condition.EndDate != null)
            {
                query = query.Where(t => t.ReleaseTime < condition.EndDate);
            }
            query = query.Where(t => t.IsDelete == false);
            query = query.OrderByDescending(t => t.ReleaseTime);

            return(new PagedList <ImportantNewsInfo>(query, condition.PageIndex, condition.PageSize));
        }
Exemplo n.º 3
0
        public IList <News_News> SearchNews(NewsCondition condition, ref Paging paging)
        {
            CupcakeEntities db = new CupcakeEntities();

            Expression <Func <News_News, bool> > where = PredicateExtensions.True <News_News>();
            if (condition.NewsType != null)
            {
                where = where.And(n => n.NewsType == condition.NewsType);
            }
            where        = where.And(n => n.IsDelete == false);
            paging.Total = db.News_News.Where(n => n.NewsType == condition.NewsType).Count();
            return(db.News_News.Where(where).OrderBy(n => n.CreateDate)
                   .Skip(paging.PageSize * paging.PageIndex)
                   .Take(paging.PageSize).ToList());
        }
Exemplo n.º 4
0
        public IPagedList <News> SearchNews(NewsCondition condition)
        {
            var query = repository.Table;

            if (!string.IsNullOrEmpty(condition.Title))
            {
                query = query.Where(t => t.Title.Contains(condition.Title));
            }
            if (condition.NewsType != null)
            {
                query = query.Where(t => t.NewsType == condition.NewsType);
            }

            query = query.Where(t => t.IsDelete == false);
            query = query.OrderByDescending(t => t.CreateDate);

            return(new PagedList <News>(query, condition.PageIndex, condition.PageSize));
        }