Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public EventLatestResult GetList(EventLatestListFilter filter, int?customPageSize = null, string isIndex = null)
        {
            EventLatestResult      result = new EventLatestResult();
            List <EventLatestData> data   = new List <EventLatestData>();

            using (var db = new TCGDB(_connectionString))
            {
                try
                {
                    var source = db.ACTIVITY
                                 .AsEnumerable()
                                 .Where(s => (string.IsNullOrEmpty(filter.LangCode) ? true : s.LANG_ID == filter.LangCode) &&
                                        s.STATUS == "Y" &&
                                        (string.IsNullOrEmpty(isIndex) ? true : s.IS_INDEX == isIndex))
                                 .OrderByDescending(o => o.SORT) //排序大到小、發布日期新到舊、建檔日期新到舊
                                 .ThenByDescending(s => s.C_DATE)
                                 .ThenByDescending(d => d.BD_DT)
                                 .ToList();

                    foreach (var item in source)
                    {
                        EventLatestData temp = new EventLatestData()
                        {
                            ID                = item.ID,
                            Title             = item.C_TITLE,
                            Img               = GetMainImg(item.ID),
                            PagingList        = GetPagingListByID(item.ID),
                            PublishDateString = item.C_DATE.Value.ToString("yyyy-MM-dd"),
                            Sort              = item.SORT.Value,
                            BD_DTString       = item.BD_DT.Value.ToString("yyyy-MM-dd"),
                        };
                        temp.Remark = GetFirstPagingRemark(temp.PagingList);
                        data.Add(temp);
                    }

                    result.Data = data;
                    result      = this.ListPagination(ref result, filter.CurrentPage, customPageSize ?? Convert.ToInt32(PublicMethodRepository.GetConfigAppSetting("DefaultPageSize")));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            return(result);
        }
        /// <summary>
        /// 列表
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        public AnnouncementLatestResult GetList(AnnouncementLatestFilter filter, int?costomPageSize = null, string isIndex = null)
        {
            AnnouncementLatestResult      result = new AnnouncementLatestResult();
            List <AnnouncementLatestData> data   = new List <AnnouncementLatestData>();

            using (var db = new TCGDB(_connectionString))
            {
                try
                {
                    var source = db.NEWS
                                 .AsEnumerable()
                                 .Where(s => (string.IsNullOrEmpty(filter.LangCode) ? true : s.LANG_ID == filter.LangCode) &&
                                        s.STATUS == "Y" && (filter.TypeID == null ? true : s.CATE_ID == (int)filter.TypeID) &&
                                        (string.IsNullOrEmpty(isIndex) ? true : s.IS_INDEX == isIndex))
                                 .OrderByDescending(o => o.SORT) //排序大到小、發布日期新到舊、建檔日期新到舊
                                 .ThenByDescending(s => s.N_DATE)
                                 .ThenByDescending(d => d.BD_DT)
                                 .ToList();

                    foreach (var item in source)
                    {
                        AnnouncementLatestData temp = new AnnouncementLatestData()
                        {
                            ID                = item.ID,
                            Title             = item.N_TITLE,
                            Img               = GetMainImg(item.ID),
                            CateIDInfo        = GetNewsCateByID((int)item.CATE_ID, filter.LangCode),
                            PublishDateString = item.N_DATE.Value.ToString("yyyy-MM-dd"),
                            Content           = item.N_DESC.RemoveHtmlAllTags(),
                            BD_DTString       = item.BD_DT.Value.ToString("yyyy-MM-dd"),
                            Sort              = item.SORT.Value,
                        };
                        data.Add(temp);
                    }

                    result.Data = data;
                    result      = this.ListPagination(ref result, filter.CurrentPage, costomPageSize ?? Convert.ToInt32(PublicMethodRepository.GetConfigAppSetting("DefaultPageSize")));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            return(result);
        }