Ejemplo n.º 1
0
 public void UpdateTecSkillLevel(ETecSkill tecSkill, bool needSave = true)
 {
     _dbContext.DBTecSkill.Attach(tecSkill);
     _dbContext.Entry(tecSkill).Property(p => p.SkillLevel).IsModified = true;
     if (needSave)
     {
         _dbContext.SaveChanges();
     }
 }
Ejemplo n.º 2
0
        public IActionResult OnPostSaveSkillLevel(ETecSkill sk)
        {
            ResultNormal result = new ResultNormal();

            try
            {
                _TecSrv.UpdateTecSkillLevel(sk);
            }
            catch (Exception ex)
            {
                result.ErrorMsg = ex.Message;
            }

            return(new JsonResult(result));
        }
Ejemplo n.º 3
0
        public void NewTecFromUser(EUserInfo user)
        {
            int count = _dbContext.DBTecInfo.Count(t => t.UserOpenId == user.OpenId);

            if (count == 0)
            {
                int No      = 0;
                var lastTec = _dbContext.DBTecInfo.OrderByDescending(a => a.Id).FirstOrDefault();
                if (lastTec != null)
                {
                    No = (int)lastTec.Id;
                }
                No++;
                //教师信息
                ETecInfo tec = new ETecInfo
                {
                    Sex             = user.Sex,
                    Code            = EduCodeGenerator.GetTecCode(No),
                    Name            = user.Name,
                    UserOpenId      = user.OpenId,
                    WxName          = user.wx_Name,
                    Phone           = user.Phone,
                    CreatedDateTime = DateTime.Now,
                    UpdatedDateTime = DateTime.Now,
                };

                //教师技能
                _dbContext.Database.ExecuteSqlRaw(TecSrv.sql_DeleteALLTecSkill(tec.Code));

                CourseSrv courseSrv  = new CourseSrv(this._dbContext);
                var       courseList = courseSrv.GetCourseType();
                foreach (var course in courseList)
                {
                    ETecSkill ts = new ETecSkill
                    {
                        CourseType = (CourseType)course.Key,
                        SkillLevel = SkillLevel.None,
                        TecCode    = tec.Code,
                    };

                    _dbContext.DBTecSkill.Add(ts);
                }

                _dbContext.DBTecInfo.Add(tec);
                _dbContext.Database.ExecuteSqlRaw(UserSrv.sql_UpdateUserRole(UserRole.Teacher, user.OpenId));
                _dbContext.SaveChanges();
            }
        }