Exemple #1
0
        public bool IsExist(CoachCourseJoin obj)
        {
            string sql = "";

            sql = @"
SELECT Id FROM dbo.CoachCourseJoin 
WHERE StudentId=@StudentUserId AND  CourseId=@CourseId 
";
            var cmd = CommandHelper.CreateText <CoachCourse>(FetchType.Fetch, sql);

            cmd.Params.Add("@StudentUserId", obj.StudentId);
            cmd.Params.Add("@CourseId", obj.CourseId);

            var result = DbContext.GetInstance().Execute(cmd);

            if (result == null)
            {
                return(false);
            }

            if (result.Entities.Count == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        public Response Execute(User currentUser, string request)
        {
            var req      = JsonConvert.DeserializeObject <Request <GetCoachRelatedFilter> >(request);
            var courseId = req.Filter.CourseId;
            //获取要取消报名的学员列表
            var studentList = CoachHelper.GetStudentList(courseId);
            List <CoachCourseJoin> listNotJoin = new List <CoachCourseJoin>();

            foreach (var student in studentList)
            {
                CoachCourseJoin c = new CoachCourseJoin();
                c.CourseId  = courseId;
                c.CoachId   = student.CoachId;
                c.StudentId = student.UserId;
                listNotJoin.Add(c);
            }
            //取消学员课程报名
            Response result = new Response();

            if (listNotJoin.Count > 0)
            {
                result = CoachHelper.Instance.CourseNotJoin(listNotJoin);
            }
            //删除课程前先备份记录(因为这里会反算学员次数 , 备份哈记录避免后面扯皮找不到记录)
            result = BackupCourseRow(courseId);
            //删除课程
            var sql = @"DELETE CoachCourse  WHERE Id=@CourseId ";
            var cmd = CommandHelper.CreateText <ClubUser>(FetchType.Execute, sql);

            cmd.Params.Add("@CourseId", courseId);
            result = DbContext.GetInstance().Execute(cmd);
            //删除课程的说说
            result = DeleteCourseNote(courseId);
            return(result);
        }
Exemple #3
0
        /// <summary>
        /// 删除此学员的课程报名记录
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public Response DeleteCourseJoin(CoachCourseJoin obj)
        {
            var sql = @"
DELETE FROM CoachCourseJoin WHERE CourseId=@CourseId AND StudentId=@StudentUserId

";
            var cmd = CommandHelper.CreateText(FetchType.Execute, sql);

            cmd.Params.Add("@CourseId", obj.CourseId);
            cmd.Params.Add("@StudentUserId", obj.StudentId);

            var result = DbContext.GetInstance().Execute(cmd);

            return(result);
        }
        public bool HaveBalance(CoachCourseJoin obj, string cityId)
        {
            string sql = "";

            sql = @"
 SELECT 
	SUM(Amount) AS Amount
FROM dbo.CoachStudentMoney 
WHERE StudentUserId=@StudentUserId  
    AND CourseTypeId=@CourseTypeId AND CityId=@CityId
    
";
            var course = CoachHelper.Instance.GetCoacherCourse(obj.CourseId);

            if (course.Type == "027001") //大课有 有效期限制 , 私教没有
            {
                sql += " AND Deadline>GETDATE() ";
            }

            if (course.Type == "027003")  //私教才去匹配教练字段, 大课不用
            {
                sql += " AND CoachId = @CoachId ";
            }
            var cmd = CommandHelper.CreateText <CoachStudentMoney>(FetchType.Fetch, sql);

            cmd.Params.Add("@StudentUserId", obj.StudentId);
            cmd.Params.Add("@CoachId", obj.CoachId);
            cmd.Params.Add("@CourseTypeId", course.Type);
            cmd.Params.Add("@CityId", cityId);


            var result = DbContext.GetInstance().Execute(cmd);
            var money  = result.FirstEntity <CoachStudentMoney>();

            if (money == null) //没余额记录可扣
            {
                return(false);
            }

            if (money.Amount > 0) //有余额可以扣
            {
                return(true);
            }
            else // 余额次数用完了
            {
                return(false);
            }
        }
        public Response SubOne(CoachCourseJoin obj, string cityId)
        {
            var cmd = CommandHelper.CreateProcedure <CoacherApply>(text: "sp_ReserveCourseSubOne");

            cmd.Params.Add(CommandHelper.CreateParam("@StudentUserId", obj.StudentId));
            cmd.Params.Add(CommandHelper.CreateParam("@CoacherUserId", obj.CoachId));
            cmd.Params.Add(CommandHelper.CreateParam("@CourseId", obj.CourseId));
            cmd.Params.Add(CommandHelper.CreateParam("@CityId", cityId));
            cmd.Params.Add(CommandHelper.CreateParam("@ThenCourseUnitPrice", 0, DataType.Decimal, ParamDirection.Output));
            cmd.Params.Add(CommandHelper.CreateParam("@Type", "Join"));//报名
            cmd.CreateParamMsg();

            var result = DbContext.GetInstance().Execute(cmd);

            return(result);
        }
Exemple #6
0
        public Response InsertCoachCourseJoin(List <CoachStudent> studentList, string coachId, string CourseId)
        {
            List <EntityBase> entites = new List <EntityBase>();

            foreach (var item in studentList)
            {
                CoachCourseJoin obj = new CoachCourseJoin();
                obj.RowState = RowState.Added;
                obj.TrySetNewEntity();
                obj.StudentId           = item.UserId;
                obj.CourseId            = CourseId;
                obj.CoachId             = coachId;
                obj.ThenCourseUnitPrice = 0;
                entites.Add(obj);
            }

            return(DbContext.GetInstance().Execute(CommandHelper.CreateSave(entites)));
        }