Exemplo n.º 1
0
        public JsonResult PageList([FromForm] string token, [FromForm] int courseTypeId = -1, [FromForm] int pageNumber = 1, [FromForm] int pageSize = 10)
        {
            DataResult dr = new DataResult();

            try
            {
                CourseBLL courseBLL = new CourseBLL();

                int totalItemCount = courseBLL.Count(courseTypeId);
                List <CourseEntity> courseEntities = courseBLL.List(courseTypeId, pageNumber: pageNumber, pageSize: pageSize, totalCount: totalItemCount);

                if (courseEntities.Count > 0)
                {
                    CourseOrderBLL courseOrderBLL = new CourseOrderBLL();
                    courseEntities.ForEach(it =>
                    {
                        it.countSold = courseOrderBLL.GetCountByCourseId(it.courseId);
                    });
                }

                PageData pageData = new PageData(courseEntities, pageNumber, pageSize, totalItemCount);

                dr.code = "200";
                dr.data = pageData;
            }
            catch (Exception ex)
            {
                dr.code = "999";
                dr.msg  = ex.Message;
            }

            return(Json(dr));
        }