Ejemplo n.º 1
0
 /// <summary>
 /// 刷新分数
 /// </summary>
 /// <param name="pLoggingSessionInfo"></param>
 public void RefreshCourseAvgScore(LoggingSessionInfo pLoggingSessionInfo, string pOnlineCourseId)
 {
     try
     {
         ItemCommentBLL       commentBll = new ItemCommentBLL(pLoggingSessionInfo);
         int                  avgStar    = commentBll.GetCourseAvgStar(pOnlineCourseId);
         MLOnlineCourseBLL    courseBll  = new MLOnlineCourseBLL(pLoggingSessionInfo);
         MLOnlineCourseEntity entity     = courseBll.GetByID(pOnlineCourseId);
         if (entity != null)
         {
             entity.AverageStar = avgStar;
             courseBll.Update(entity);
         }
     }
     catch (Exception ex)
     { }
 }
        public string GetOnlineCourseList(string pRequest)
        {
            var rd     = new APIResponse <GetOnlineCourseListRD>();
            var rdData = new GetOnlineCourseListRD();
            var rp     = pRequest.DeserializeJSONTo <APIRequest <GetOnlineCourseListRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);

            try
            {
                //判断:courseType<=0查询所有
                string courseType = string.Empty;
                if (rp.Parameters.CourseType > 0)
                {
                    courseType = rp.Parameters.CourseType.ToString();
                }

                MLOnlineCourseBLL courseBll = new MLOnlineCourseBLL(loggingSessionInfo);
                DataTable         dTbl      = courseBll.GetOnlineCourse(courseType, rp.Parameters.SortKey, rp.Parameters.SortOrientation, rp.Parameters.PageIndex, rp.Parameters.PageSize);
                if (dTbl != null)
                {
                    rdData.CourseList = DataTableToObject.ConvertToList <OnlineCourse>(dTbl);
                }
                rd.ResultCode = 0;
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            rd.Data = rdData;
            return(rd.ToJSON());
        }
Ejemplo n.º 3
0
        public string SearchCourse(string pRequest)
        {
            var rd     = new APIResponse <SearchCourseRD>();
            var rdData = new SearchCourseRD();
            var rp     = pRequest.DeserializeJSONTo <APIRequest <SearchCourseRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);

            try
            {
                MLOnlineCourseBLL courseBll = new MLOnlineCourseBLL(loggingSessionInfo);
                DataTable         dTbl      = courseBll.SearchOnlineCourse(rp.Parameters.Keyword, 0, 3000);
                if (dTbl != null)
                {
                    rdData.CourseList = DataTableToObject.ConvertToList <OnlineCourse>(dTbl);
                }
                rd.ResultCode = 0;
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            rd.Data = rdData;
            return(rd.ToJSON());
        }
        public string GetOnlineCourseDetail(string pRequest)
        {
            var rd     = new APIResponse <GetOnlineCourseDetailRD>();
            var rdData = new GetOnlineCourseDetailRD();
            var rp     = pRequest.DeserializeJSONTo <APIRequest <GetOnlineCourseDetailRP> >();

            if (rp.Parameters == null)
            {
                throw new ArgumentException();
            }

            if (rp.Parameters != null)
            {
                rp.Parameters.Validate();
            }

            var loggingSessionInfo = Default.GetBSLoggingSession(rp.CustomerID, rp.UserID);

            try
            {
                MLOnlineCourseBLL courseBll = new MLOnlineCourseBLL(loggingSessionInfo);

                //课程信息
                DataTable    dTbl   = courseBll.SearchOnlineCourseDetail(rp.Parameters.OnlineCourseID);
                OnlineCourse entity = null;
                if (dTbl != null && dTbl.Rows.Count > 0)
                {
                    entity = DataTableToObject.ConvertToObject <OnlineCourse>(dTbl.Rows[0]);
                }

                //课程附件列表
                List <CourseWare> list     = new List <CourseWare>();
                MLCourseWareBLL   wareBll  = new MLCourseWareBLL(loggingSessionInfo);
                DataTable         dTblWare = wareBll.GetCourseWare(rp.Parameters.OnlineCourseID);
                if (dTblWare != null && dTblWare.Rows.Count > 0)
                {
                    list = DataTableToObject.ConvertToList <CourseWare>(dTblWare);
                }

                //构建CourseDetail对象
                CourseDetail detail = new CourseDetail
                {
                    OnlineCourse   = entity,
                    CourseWareList = list
                };
                rdData.CourseDetail = detail;

                //添加访问次数
                try
                {
                    MLOnlineCourseEntity courseEntity = courseBll.GetByID(rp.Parameters.OnlineCourseID);
                    if (courseEntity != null)
                    {
                        courseEntity.AccessCount++;
                        courseBll.Update(courseEntity);
                    }
                }
                catch (Exception ex)
                { }
                rd.ResultCode = 0;
            }
            catch (Exception ex)
            {
                rd.ResultCode = 103;
                rd.Message    = ex.Message;
            }
            rd.Data = rdData;
            return(rd.ToJSON());
        }