public JsonResult Get([FromForm] string token, [FromForm] int courseId) { DataResult dr = new DataResult(); try { if (courseId < 10000) { dr.code = "201"; dr.msg = "参数错误"; return(Json(dr)); } UserEntity userEntity = this.GetUserByToken(token); CourseOrderEntity courseOrderEntity = courseOrderBLL.GetByCourseAndUserId(courseId, userEntity.userId); dr.code = "200"; dr.msg = "成功"; dr.data = courseOrderEntity; } catch (Exception ex) { dr.code = "999"; dr.msg = ex.Message; } return(Json(dr)); }
public JsonResult GetDetailById([FromForm] string token, [FromForm] int courseId) { DataResult dr = new DataResult(); try { UserEntity userEntity = this.GetUserByToken(token); CourseOrderBLL courseOrderBLL = new CourseOrderBLL(); CourseOrderEntity courseOrderEntity = courseOrderBLL.GetByCourseAndUserId(courseId, userEntity.userId); if (courseOrderEntity == null) { dr.code = "201"; dr.msg = "未购买该课程"; return(Json(dr)); } CourseBLL courseBLL = new CourseBLL(); CourseEntity courseEntity = courseBLL.GetById(courseId); CourseSectionBLL courseSectionBLL = new CourseSectionBLL(); courseEntity.courseSectionEntities = courseSectionBLL.ListByCourseId(courseId); TeacherBLL teacherBLL = new TeacherBLL(); courseEntity.teacherEntity = teacherBLL.GetById(courseEntity.teacherId); courseEntity.countSold = courseOrderBLL.GetCountByCourseId(courseEntity.courseId); dr.code = "200"; dr.data = courseEntity; } catch (Exception ex) { dr.code = "999"; dr.msg = ex.Message; } return(Json(dr)); }