Esempio n. 1
0
 public static CourseSetScore GetSetVal(this CourseSet courseSet, CourseLearnType type, bool isSpecial)
 {
     if (type == CourseLearnType.Must || type == CourseLearnType.MustAll)
     {
         return(isSpecial ? courseSet.RequiredMajor : courseSet.RequiredCommonly);
     }
     return(isSpecial ? courseSet.ElectiveMajor : courseSet.ElectiveCommonly);
 }
Esempio n. 2
0
        /// <summary>
        /// 设置视频设置
        /// </summary>
        /// <returns></returns>
        public async Task <CourseSet> Get()
        {
            try
            {
                var result     = new CourseSet();
                var cachemodel = await _cacheManager.GetCache("CourseSetting").GetAsync("CourseSettingKey",
                                                                                        async() => await _repository.GetAll().FirstOrDefaultAsync());

                if (cachemodel != null)
                {
                    result = JsonConvert.DeserializeObject <CourseSet>(cachemodel.Content);
                }
                return(result);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 获取视频配置
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public async Task Set(CourseSet input)
        {
            input.ViewingRatio = input.ViewingRatio <= 0 ? 1 : input.ViewingRatio > 100 ? 100 : input.ViewingRatio;
            var model = await _repository.GetAll().FirstOrDefaultAsync();

            if (model != null)
            {
                model.Content = JsonConvert.SerializeObject(input);
                await _repository.UpdateAsync(model);
            }
            else
            {
                model = new CourseSetting()
                {
                    Id      = Guid.NewGuid(),
                    Content = JsonConvert.SerializeObject(input)
                };
                await _repository.InsertAsync(model);
            }
            //更新缓存
            await _cacheManager.GetCache("CourseSetting").SetAsync("CourseSettingKey", model);
        }