コード例 #1
0
        public IActionResult OnPostSubmitTrial(string courseCode, int Lesson, string date)
        {
            ResultNormal result = new ResultNormal();
            var          times  = StaticDataSrv.TrialTime;

            try
            {
                var us = base.GetUserSession(false);
                if (us != null)
                {
                    var cls = _CourseSrv.GetCourseInfoClass(courseCode);

                    var errorMsg = _CourseSrv.VerifyUserTrial(us.OpenId, (int)cls.CourseType, date, Lesson);
                    if (errorMsg == EduErrorMessage.ApplyTrial_OverSingleLimit)
                    {
                        result.ErrorMsg = "同类型课不能试听超过2次";
                    }
                    else if (errorMsg == EduErrorMessage.ApplyTrial_SameTypeExist)
                    {
                        result.ErrorMsg = "同时段已经有申请试听";
                    }
                    else
                    {
                        ETrialLog log = new ETrialLog
                        {
                            OpenId = us.OpenId,
                            //UserName = us.UserName,
                            TecCode        = cls.TecCode,
                            TecName        = cls.TecName,
                            CourseCode     = cls.CourseCode,
                            CourseName     = cls.CourseName,
                            CourseType     = (int)cls.CourseType,
                            ApplyDateTime  = DateTime.Now,
                            Lesson         = Lesson,
                            TrialDateTime  = DateTime.Parse(date),
                            TrialLogStatus = (int)TrialLogStatus.UserApply,
                        };
                        _CourseSrv.AddTrial(log);
                        _CourseSrv.SaveChanges();
                    }
                }
                else
                {
                    result.IntMsg   = -1;
                    result.ErrorMsg = "需要您重新登录!";
                }
            }
            catch (Exception ex)
            {
                result.ErrorMsg = "提交申请失败,请联系工作人员";
                NLogHelper.ErrorTxt($"ApplyTrialModel[OnPostSubmitTrial]:{ex.Message}");
            }
            return(new JsonResult(result));
        }