Beispiel #1
0
        public NewsListResultModel DoGetList(NewsListFilterModel filterModel)
        {
            PublicMethodRepository.FilterXss(filterModel);
            NewsListResultModel result = new NewsListResultModel();
            List <NEWS>         data   = new List <NEWS>();

            try
            {
                data = DB.NEWS.ToList();

                //關鍵字搜尋
                if (!string.IsNullOrEmpty(filterModel.QueryString))
                {
                    this.ListFilter(filterModel.QueryString, ref data);
                }

                //發佈日期搜尋
                if (!string.IsNullOrEmpty(filterModel.PublishDate))
                {
                    this.ListDateFilter(filterModel.PublishDate, ref data);
                }

                //首頁顯示
                if (!string.IsNullOrEmpty(filterModel.DisplayForHomePage))
                {
                    this.ListStatusFilter(filterModel.DisplayForHomePage, "DisplayHome", ref data);
                }

                //上下架
                if (!string.IsNullOrEmpty(filterModel.Disable))
                {
                    this.ListStatusFilter(filterModel.Disable, "Disable", ref data);
                }

                //排序
                this.ListSort(filterModel.SortColumn, ref data);
                PaginationResult pagination;
                //分頁
                this.ListPageList(filterModel.CurrentPage, ref data, out pagination);
                result.Pagination = pagination;
                foreach (var d in data)
                {
                    PublicMethodRepository.HtmlDecode(d);
                }

                result.Data = data;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
        public override object DoGetList <TFilter>(TFilter model, Language language)
        {
            NewsListFilterModel      filterModel = (model as NewsListFilterModel);
            NewsListResultModel      result      = new NewsListResultModel();
            List <NewsListDataModel> data        = new List <NewsListDataModel>();

            try
            {
                data = DB.WBNEWS.Select(s => new NewsListDataModel()
                {
                    ID                 = s.ID,
                    Title              = s.NEWS_TITLE,
                    PublishDateStr     = s.PUB_DT,
                    DisplayForFront    = (bool)s.DIS_FRONT_ST,
                    DisplayForHomePage = (bool)s.DIS_HOME_ST,
                    Sort               = s.SR_SQ,
                    Language           = s.LANG_CD
                })
                       .ToList();
                //語系搜尋
                if (!language.Equals(Language.NotSet))
                {
                    this.NewsListFilterLanguage(language, ref data);
                }
                //關鍵字搜尋
                if (!string.IsNullOrEmpty(filterModel.QueryString))
                {
                    this.NewsListFilter(filterModel.QueryString, ref data);
                }
                //發佈日期搜尋
                if (!string.IsNullOrEmpty(filterModel.PublishDate))
                {
                    this.NewsListDateFilter(filterModel.PublishDate, ref data);
                }

                //前台顯示
                if (!string.IsNullOrEmpty(filterModel.DisplayForFrontEnd))
                {
                    this.NewsListStatusFilter(filterModel.DisplayForFrontEnd, "F", ref data);
                }

                //首頁顯示
                if (!string.IsNullOrEmpty(filterModel.DisplayForHomePage))
                {
                    this.NewsListStatusFilter(filterModel.DisplayForHomePage, "H", ref data);
                }

                //排序
                this.NewsListSort(filterModel.SortColumn, filterModel.Status, ref data);
                PaginationResult pagination;
                //分頁
                this.NewsListPageList(filterModel.CurrentPage, ref data, out pagination);
                result.Pagination = pagination;
                result.Data       = data;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }