Ejemplo n.º 1
0
        public Response Execute(User currentUser, string request)
        {
            var    req = JsonConvert.DeserializeObject <Request <GetCoachRelatedFilter> >(request);
            string sql = @"
SELECT 
    a.*,
    b.Name AS VenueName,
	c.Name AS CourseGoalName,
    c.Code AS CourseGoalCode,
	CoachName = dbo.fn_GetUserName(d.Id),
	BigCourseName = e.Name,
	e.Price AS BigCourseUnitPrice,
	f.Grade AS CoachGrade,
    d.Code AS CoachCode,
    b.Lng  AS VenueLng ,
    b.Lat  AS VenueLat ,
    b.Address AS VenueAddress,
    e.CourseContent AS CourseContentDetail,
    Score=(SELECT AVG(Score) FROM dbo.CoachComment WHERE CourseId=a.Id ),
	MyScore=(SELECT ISNULL(Score,0) FROM dbo.CoachComment WHERE CommentatorId=@CurrentUserId AND CourseId=a.Id )
FROM dbo.CoachCourse a
LEFT JOIN dbo.Venue b ON a.VenueId = b.Id
LEFT JOIN dbo.SysDic c ON c.Code = a.CourseGoalCode AND c.Code!=''
LEFT JOIN dbo.UserAccount d ON a.CoachId = d.Id
LEFT JOIN dbo.CoachBigCourseInfo e ON e.Id = a.BigCourseId
LEFT JOIN dbo.Coach f ON a.CoachId=f.Id
 
WHERE
     a.Id = @Id
               
";

            var cmd = CommandHelper.CreateText <CoachCourse>(FetchType.Fetch, sql);

            cmd.Params.Add("@Id", req.Filter.CourseId);
            cmd.Params.Add("@CurrentUserId", req.Filter.CurrentUserId);

            var         result      = DbContext.GetInstance().Execute(cmd);
            CoachCourse coachCourse = result.FirstEntity <CoachCourse>();

            if (coachCourse != null)
            {
                //获取个人信息列表
                GetPersonInfoList(coachCourse);
                //CourseName 计算赋值
                SetCourseName(coachCourse);
                //获取我的余额(界面最外层用)
                GetMyBalance(coachCourse, req.Filter.CurrentUserId);
                //获取教练或大课的单价
                GetUnitPrice(coachCourse);
                //计算课程状态
                CoachHelper.Instance.CountCourseState(coachCourse);
                //返回附件
                coachCourse.TryGetFiles();
                CoachHelper.Instance.SetCourseAvgScore(coachCourse);
            }
            return(result);
        }
Ejemplo n.º 2
0
        public Response Execute(User currentUser, string request)
        {
            var    req = JsonConvert.DeserializeObject <Request <GetCoachRelatedFilter> >(request);
            string sql = @"
SELECT 
    a.*,
    b.Name AS VenueName,
	c.Name AS CourseGoalName,
	CoachName = dbo.fn_GetUserName(d.Id),
	BigCourseName = e.Name,
	f.Name AS TypeName,
	b.Address AS VenueAddress,
    e.CourseContent AS CourseContentDetail
FROM dbo.CoachCourse a
LEFT JOIN dbo.Venue b ON a.VenueId = b.Id
LEFT JOIN dbo.SysDic c ON c.Code = a.CourseGoalCode AND c.Code!=''
LEFT JOIN dbo.UserAccount d ON a.CoachId = d.Id
LEFT JOIN dbo.CoachBigCourseInfo e ON e.Id = a.BigCourseId
LEFT JOIN dbo.BaseData f ON a.Type=f.Id
WHERE
     a.Id = @Id
               
";
            var    cmd = CommandHelper.CreateText <CoachCourse>(FetchType.Fetch, sql);

            cmd.Params.Add("@Id", req.Filter.CourseId);
            var result = DbContext.GetInstance().Execute(cmd);

            CoachCourse coachCourse = result.FirstEntity <CoachCourse>();

            if (coachCourse != null)
            {
                //个人信息列表
                GetPersonInfoList(coachCourse);
                //CourseName 计算赋值
                if (coachCourse.Type == CoachDic.BigCourse)
                {
                    coachCourse.CourseName = coachCourse.BigCourseName;
                }
                else if (coachCourse.Type == CoachDic.PrivateCourse)
                {
                    coachCourse.CourseName = coachCourse.CoachName;
                }

                //计算上下课打卡按钮状态
                CountStartEndCard(coachCourse);
                //获取附件
                coachCourse.TryGetFiles();
            }

            return(result);
        }