public static ListModuleService Create(ListMethodType methodType)
        {
            ListModuleService listManageModule;

            switch (methodType)
            {
            case ListMethodType.NEWS:
                listManageModule = new NewsModule();
                break;

            case ListMethodType.PRODUCT:
                listManageModule = new ProductModule();
                break;

            case ListMethodType.PRODUCTKIND:
                listManageModule = new ProductKindModule();
                break;

            case ListMethodType.WORKS:
                listManageModule = new WorksModule();
                break;

            case ListMethodType.AGENT:
                listManageModule = new AgentModule();
                break;

            default:
                listManageModule = null;
                break;
            }
            return(listManageModule);
        }
        public static ListBaseService Create(ListMethodType methodType)
        {
            ListBaseService listManageModule = null;

            switch (methodType)
            {
            case ListMethodType.PRODUCT:
                listManageModule = new ProductsModule <ListFilterBase, PRODUCT>();
                break;

            default:
                listManageModule = null;
                break;
            }
            return(listManageModule);
        }
Пример #3
0
        /// <summary>
        /// [前台] 列表分頁處理
        /// </summary>
        /// <param name="data"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        public dynamic ListPageFrontEnd <T>(IEnumerable <T> data, int page, int pageSize, ListMethodType methodType)
        {
            int startRow = 0;
            PaginationResult paginationResult = null;

            if (pageSize > 0)
            {
                //分頁
                startRow         = (page - 1) * pageSize;
                paginationResult = new PaginationResult()
                {
                    CurrentPage = page,
                    DataCount   = data.Count(),
                    PageSize    = pageSize,
                    FirstPage   = 1,
                    LastPage    = data.Count() == 0 ? 1 : Convert.ToInt32(Math.Ceiling((decimal)data.Count() / pageSize))
                };
            }

            dynamic result = null;

            switch (methodType)
            {
            case ListMethodType.NotSet:
                break;

            case ListMethodType.NEWS:
                result      = new NewsFrontEndListDataModel();
                result.Data = data.Skip(startRow).Take(pageSize).ToList();
                break;

            //case ListMethodType.FEEDBACK:
            //    result = new FeedbackFrontEndListDataModel();
            //    result.Data = data.Skip(startRow).Take(pageSize).ToList();
            //    break;

            case ListMethodType.PRODUCT:
                result      = new ProductFrontEndListDataModel();
                result.Data = data.ToList();
                break;

            default:
                break;
            }
            result.Pagination = paginationResult;
            return(result);
        }