public IPagedList <MessageOpenAdministrativeIndexInfo> SearchNews(MessageOpenAdministrativeIndexCondition condition)
        {
            var query = repository.Table;

            if (!string.IsNullOrEmpty(condition.Title))
            {
                query = query.Where(t => t.Title.Contains(condition.Title));
            }
            if (condition.Title != null)
            {
                query = query.Where(t => t.Title == condition.Title);
            }
            if (condition.IsTop != null)
            {
                bool IsTop = bool.Parse(DataDictionaryHelper.GetValue((Guid)condition.IsTop));
                query = query.Where(t => t.IsTop == IsTop);
            }
            if (condition.Department != null)
            {
                query = query.Where(t => t.Department.Contains(condition.Department));
            }

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

            return(new PagedList <MessageOpenAdministrativeIndexInfo>(query, condition.PageIndex, condition.PageSize));
        }
Example #2
0
        public ActionResult Index(MessageOpenAdministrativeIndexCondition condition)
        {
            var info   = service.SearchNews(condition);
            var models = new PagedList <MessageOpenAdministrativeIndexInfo>(info, info.Paging);

            return(View(PluginHelper.GetViewPath(this.GetType(), "Index"), models));
        }