public JsonResult List([FromForm] string token)
        {
            DataResult dr = new DataResult();

            try
            {
                CourseRecommendBLL           courseRecommendBLL      = new CourseRecommendBLL();
                CourseBLL                    courseBLL               = new CourseBLL();
                CourseOrderBLL               courseOrderBLL          = new CourseOrderBLL();
                List <CourseRecommendEntity> courseRecommendEntities = courseRecommendBLL.ActionDal.ActionDBAccess.Queryable <CourseRecommendEntity>().ToList();

                courseRecommendEntities.ForEach(it =>
                {
                    List <int> vs = courseRecommendBLL.ActionDal.ActionDBAccess.Queryable <CourseRecommendCorrelationEntity>()
                                    .Where(itt => itt.courseRecommendId == it.courseRecommendId)
                                    .Select(itt => itt.courseId)
                                    .ToList();
                    if (vs.Count > 0)
                    {
                        it.courseEntities = courseBLL.ListByIdInts(vs);
                    }

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

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

            return(Json(dr));
        }
 public CourseRecommendController()
 {
     courseRecommendBLL = new CourseRecommendBLL();
 }
Beispiel #3
0
        public object makeClassStatus(Tag tag)
        {
            object collection = null;
            List <CourseRecommend> list;
            string softVersion = ((StringLiteral)tag.AttributeValue("softVersion")).Content;

            CourseRecommendBLL crBLL = Factory.BusinessFactory.CreateBll <CourseRecommendBLL>();

            list = crBLL.GetCourse(softVersion, 1);
            if (list != null)
            {
                collection = list;
            }
            else
            {
                return("");
            }
            //Common.Loger.Info(softVersion);
            Expression expVar = tag.AttributeValue("var");

            if (expVar == null)
            {
                throw new TemplateRuntimeException("foreach 语法缺少 var 属性定义.", tag.Line, tag.Col);
            }

            object varObject = EvalExpression(expVar);

            if (varObject == null)
            {
                varObject = "foreach";
            }
            string     varname   = varObject.ToString();
            Expression expIndex  = tag.AttributeValue("index");
            string     indexname = null;

            if (expIndex != null)
            {
                object obj = EvalExpression(expIndex);
                if (obj != null)
                {
                    indexname = obj.ToString();
                }
            }
            //判断是否循环的最后一条标识
            Expression islastExp = tag.AttributeValue("islast");
            string     islast    = null;

            if (islastExp != null)
            {
                object obj = EvalExpression(islastExp);
                if (obj != null)
                {
                    islast = obj.ToString();
                }
            }
            IEnumerator ienum = ((IEnumerable)collection).GetEnumerator();
            int         index = 0;

            if (islast != null)
            {
                variables[islast] = false;
            }
            while (ienum.MoveNext())
            {
                index++;
                if (index == ((List <CourseRecommend>)collection).Count && islast != null)
                {
                    variables[islast] = true;
                }
                object value = ienum.Current;
                variables[varname] = value;
                if (indexname != null)
                {
                    variables[indexname] = index;
                }

                ProcessElements(tag.InnerElements);
            }

            return(collection);
        }