// 焦點專欄 - 列表 public ActionResult EducationList(int?eduTypeID, int?page) { if (!eduTypeID.HasValue) { return(View()); } //======語系取得======== string langCd = GetLang(); //====================== EducationListFilter filter = new EducationListFilter() { CurrentPage = page ?? 1, LangCode = langCd }; eduTypeID = eduTypeID ?? 1; EducationRepository repo = new EducationRepository(); EducationResult mdoel = repo.GetList((int)eduTypeID, filter); GetLang(); return(View(mdoel)); }
/// <summary> /// 列表 /// </summary> /// <param name="filter"></param> /// <returns></returns> public EducationResult GetList(int eduTypeID, EducationListFilter filter, int?coustomPageSize = null, string isIndex = null) { EducationResult result = new EducationResult(); List <EducationData> data = new List <EducationData>(); using (var db = new TCGDB(_connectionString)) { try { var source = db.EDU .AsEnumerable() .Where(s => (string.IsNullOrEmpty(filter.LangCode) ? true : s.LANG_ID == filter.LangCode) && s.STATUS == "Y" && s.CATE_ID == eduTypeID) .OrderByDescending(o => o.SORT) //排序大到小、發布日期新到舊、資料建檔日期新到舊 .ThenByDescending(s => s.C_DATE) .ThenByDescending(d => d.BD_DT) .ToList(); foreach (var item in source) { EducationData temp = new EducationData() { ID = item.ID, Title = item.C_TITLE, PagingList = GetPagingListByID(item.ID), PublishDateString = item.C_DATE.Value.ToString("yyyy-MM-dd"), }; temp.Remark = GetFirstPagingRemark(temp.PagingList); data.Add(temp); } result.Data = data; result = this.ListPagination(ref result, filter.CurrentPage, coustomPageSize ?? Convert.ToInt32(PublicMethodRepository.GetConfigAppSetting("DefaultPageSize"))); } catch (Exception ex) { throw ex; } } result.EduTypeInfo = GetEduCateByID(eduTypeID, filter.LangCode); return(result); }