예제 #1
0
        public ActionResult <DataResult> CourseList(int courseRecommendId, List <int> courseIdInts)
        {
            DataResult dataResult = new DataResult();

            try
            {
                int rows = 0;
                CourseRecommendCorrelationBLL courseRecommendCorrelationBLL = new CourseRecommendCorrelationBLL();

                List <CourseRecommendCorrelationEntity> courseRecommendCorrelationEntities = courseRecommendCorrelationBLL.ListByCourseRecommendId(courseRecommendId);

                if (courseRecommendCorrelationEntities.Count > 0 || courseIdInts.Count > 0)
                {
                    if (courseRecommendCorrelationEntities.Count > 0)
                    {
                        rows = courseRecommendCorrelationBLL.ActionDal.ActionDBAccess.Deleteable(courseRecommendCorrelationEntities).ExecuteCommand();
                    }
                    if (courseIdInts != null)
                    {
                        List <CourseRecommendCorrelationEntity> courseRecommendCorrelations = new List <CourseRecommendCorrelationEntity>();
                        courseIdInts.ForEach(it =>
                        {
                            courseRecommendCorrelations.Add(new CourseRecommendCorrelationEntity()
                            {
                                courseId          = it,
                                courseRecommendId = courseRecommendId,
                                createDate        = DateTime.Now
                            });
                        });
                        rows = courseRecommendCorrelationBLL.ActionDal.ActionDBAccess.Insertable(courseRecommendCorrelations).ExecuteCommand();
                    }
                }

                dataResult.code = "200";
                dataResult.msg  = "成功";
            }
            catch (Exception e)
            {
                dataResult.code = "999";
                dataResult.msg  = e.Message;
                return(dataResult);
            }

            return(dataResult);
        }
예제 #2
0
        public ActionResult <DataResult> ListById(int id)
        {
            DataResult dataResult = new DataResult();

            try
            {
                CourseRecommendCorrelationBLL courseRecommendCorrelationBLL = new CourseRecommendCorrelationBLL();

                List <CourseRecommendCorrelationEntity> courseRecommendCorrelationEntities = courseRecommendCorrelationBLL.ListByCourseRecommendId(id);

                dataResult.data = courseRecommendCorrelationEntities;
                dataResult.code = "200";
                dataResult.msg  = "成功";
            }
            catch (Exception e)
            {
                dataResult.code = "999";
                dataResult.msg  = e.Message;
                return(dataResult);
            }

            return(dataResult);
        }