Example #1
0
        public IActionResult OnPostSubmit(List <string> lessonCodeList, bool useRightNow = false)
        {
            ResultNormal result = new ResultNormal();

            try
            {
                var us = base.GetUserSession(false);
                if (us != null)
                {
                    var needRecharge = UserSession.NeedRecharge(us, CourseScheduleType.Standard);
                    if (needRecharge < 0)
                    {
                        string errorMsg = $"您的余额不足,请去充值";
                        result.ErrorMsg = errorMsg;
                        result.IntMsg   = -2;
                        return(new JsonResult(result));
                    }
                    List <EUserCourse> ucList = new List <EUserCourse>();
                    foreach (var lc in lessonCodeList)
                    {
                        EUserCourse uc = new EUserCourse
                        {
                            CourseScheduleType = CourseScheduleType.Standard,
                            CreateDateTime     = DateTime.Now,
                            LessonCode         = lc,
                            UseRightNow        = useRightNow,
                            UserOpenId         = us.OpenId
                        };
                        ucList.Add(uc);
                    }
                    _BusinessSrv.UserSelectNewCourses(us.OpenId, ucList, CourseScheduleType.Standard, useRightNow);

                    //更新Session是否跳过当天
                    us.CourseSkipToday = useRightNow;

                    SetUserSesion(us);
                }
                else
                {
                    result.IntMsg   = -1;
                    result.ErrorMsg = "请重新登陆";
                }
            }
            catch (EduException ex)
            {
                result.ErrorMsg = ex.Message;
            }
            catch (Exception ex)
            {
                result.ErrorMsg = "提交数据错误!请联系管理员或稍后再试";
                NLogHelper.ErrorTxt($"标准班课程选择[OnPostSubmit]:{ex.Message}");
            }
            return(new JsonResult(result));
        }
Example #2
0
        public List <EUserCourse> CreateNewCourse(string openId, string lessonCode, CourseScheduleType courseScheduleType)
        {
            EUserCourse eUserCourse = new EUserCourse
            {
                CourseScheduleType = courseScheduleType,
                CreateDateTime     = DateTime.Now,
                LessonCode         = lessonCode,
                UserOpenId         = openId,
                UseRightNow        = false,
            };
            List <EUserCourse> list = new List <EUserCourse>();

            list.Add(eUserCourse);

            return(list);
        }