コード例 #1
0
        /// <summary>
        /// </summary>
        /// <param name="keyword">
        /// </param>
        /// <param name="ordering">
        /// </param>
        /// <param name="pageIndex">
        /// </param>
        /// <param name="pageSize">
        /// </param>
        /// <param name="search">
        /// </param>
        /// <returns>
        /// </returns>
        public async Task <IActionResult> Index(string keyword, string ordering, int pageIndex = 1, int pageSize = 20, bool search = false, bool toExcelFile = false)
        {
            ViewBag.Import = true; //允许导入数据

            var model =
                _iCourseTypeService.GetAll()
                .Select(
                    a =>
                    new
            {
                a.Name,
                a.SystemId,
                a.Enable,
                a.Hot,
                a.Id
            }).Search(keyword);

            if (search)
            {
                model = model.Search(Request.Query);
            }
            if (!string.IsNullOrEmpty(ordering))
            {
                model = model.OrderBy(ordering);
            }
            if (toExcelFile)
            {
                return(model.ToExcelFile());
            }

            return(View(model.PageResult(pageIndex, pageSize)));
        }
コード例 #2
0
ファイル: CourseTypesController.cs プロジェクト: jose2a/ADYC
        public IHttpActionResult Get()
        {
            var courseTypes = _courseTypeService.GetAll();

            return(Ok(courseTypes
                      .Select(ct =>
            {
                return GetCourseTypeDto(ct);
            })));
        }
コード例 #3
0
 public IEnumerable <CourseTypeViewModel> GetAll()
 {
     return(Mapper.Map <IEnumerable <CourseTypeViewModel> >(courseTypeService.GetAll()));
 }