Example #1
0
        /// <summary>
        /// 根據新增學習圈建立驗證碼
        /// </summary>
        /// <param name="circleKey"></param>
        /// <returns></returns>
        public bool CreateFromCreateLearningCircle(string circleKey)
        {
            var learningCircleService = new LearningCircleService();
            var learningCircleInfo    = learningCircleService.GetDetailByOuterKey(circleKey.ToLower());

            if (learningCircleInfo == null)
            {
                return(false);
            }
            var codeService  = new CaptchaHelper();
            var code         = codeService.GenerateRandomText(10);
            var checkHadCode = _uow.MemberInviteRepo.GetFirst(t => t.CircleKey.ToLower() == circleKey.ToLower() && t.Enable == true && t.IsCourseCode == true);

            if (checkHadCode == null)
            {
                var entity = new MemberInvite()
                {
                    CircleKey    = circleKey.ToLower(),
                    Code         = code.ToLower(),
                    CreateDate   = DateTime.UtcNow,
                    Enable       = true,
                    InviteEmail  = null,
                    InviteUrl    = null,
                    IsCourseCode = true,
                    Type         = 0
                };
                _uow.DbContext.MemberInvite.Add(entity);
                _uow.SaveChanges();
            }
            return(true);
        }