示例#1
0
        public IActionResult OnPostSave(List <ECourseSchedule> list)
        {
            ResultNormal result = new ResultNormal();

            try
            {
                List <ECourseSchedule> newList = new List <ECourseSchedule>();
                foreach (ECourseSchedule es in list)
                {
                    es.LessonCode = $"{es.Year}_{es.Day}_{es.Lesson}_{es.CourseCode}_{es.LessonNo}_{es.CourseScheduleType}";
                    if (es.Id == 0)
                    {
                        newList.Add(es);
                    }
                }

                if (newList.Count > 0)
                {
                    _CourseSrv.AddRange(newList);

                    _CourseSrv.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                result.ErrorMsg = ex.Message;
            }
            return(new JsonResult(result));
        }
        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));
        }
示例#3
0
        public IActionResult OnPostSave(List <ECourseInfo> couseList, List <ECourseInfoClass> classList)
        {
            ResultList <SlKiV> result = new ResultList <SlKiV>();
            bool needSave             = false;

            try
            {
                _CourseSrv.BeginTrans();
                result.List = new List <SlKiV>();
                if (couseList.Count > 0)
                {
                    _CourseSrv.DelByType(couseList[0].CourseType);
                    foreach (var obj in couseList)
                    {
                        _CourseSrv.Add(obj, false);

                        result.List.Add(new SlKiV
                        {
                            Key   = obj.Id,
                            Value = obj.Level
                        });
                    }
                    needSave = true;
                }
                if (classList.Count > 0)
                {
                    foreach (var cls in classList)
                    {
                        _CourseSrv.CreateOrUpdateClass(cls);
                    }
                }
                if (needSave)
                {
                    _CourseSrv.SaveChanges();
                }

                _CourseSrv.CommitTrans();
            }
            catch (Exception ex)
            {
                _CourseSrv.RollBackTrans();
                result.ErrorMsg = ex.Message;
            }

            return(new JsonResult(result));
        }
示例#4
0
        public IActionResult OnPostUpdateTrial(RTrialLog updateTrial)
        {
            ResultNormal result = new ResultNormal();
            var          times  = StaticDataSrv.TrialTime;
            bool         needWX = false;

            try
            {
                if (updateTrial.Id <= 0)
                {
                    result.ErrorMsg = "没有找到试听课,无法保存!";
                }
                else
                {
                    ETrialLog origTrial = _CourseSrv.GetTrialLog(updateTrial.Id);

                    origTrial.Lesson        = updateTrial.Lesson;
                    origTrial.TrialDateTime = updateTrial.TrialDateTime;
                    origTrial.CourseCode    = updateTrial.CourseCode;

                    var cls = _CourseSrv.GetCourseInfoClass(origTrial.CourseCode);
                    origTrial.TecCode    = cls.TecCode;
                    origTrial.TecName    = cls.TecName;
                    origTrial.CourseType = (int)cls.CourseType;
                    origTrial.CourseName = cls.CourseName;

                    var ui = _UserSrv.GetUserInfo(updateTrial.OpenId);

                    ui.Phone       = updateTrial.UserPhone;
                    ui.SalesOpenId = updateTrial.SalesOpenId;

                    if (origTrial.TrialLogStatus == (int)TrialLogStatus.UserApply)
                    {
                        needWX = true;
                        origTrial.TrialLogStatus = (int)TrialLogStatus.TecConfirm;
                        //返佣
                    }
                    _CourseSrv.SaveChanges();

                    //微信发送
                    if (needWX)
                    {
                        TecTrialRemindTemplate wxMessage = new TecTrialRemindTemplate();
                        RTrialLog rTrialLog = new RTrialLog();
                        rTrialLog.InitFromETrialLog(origTrial);
                        rTrialLog.SalesOpenId  = updateTrial.SalesOpenId;
                        rTrialLog.SalesName    = updateTrial.SalesName;
                        rTrialLog.TrialTimeStr = times[rTrialLog.Lesson].TimeRange;
                        rTrialLog.UserRealName = ui.ChildName;
                        var teacher = _TecSrv.Get(origTrial.TecCode);
                        if (teacher != null)
                        {
                            //  teacher.UserOpenId = "oh6cV1QhPLj6XPesheYUQ4XtuGTs";
                            wxMessage.data = wxMessage.GenerateData(teacher.UserOpenId, rTrialLog);
                            result         = WXApi.SendTemplateMessage <TecTrialRemindTemplate>(wxMessage);
                            result.IntMsg  = 10;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                result.ErrorMsg = ex.Message;
            }

            return(new JsonResult(result));
        }