Beispiel #1
0
        public async Task <GetLastEmailHistoryCodeInfoByRecipientIdResultDto> GetLastEmailHistoryCodeInfoByRecipientId(string recipientId)
        {
            var emailhistoryInfo = (await _context
                                    .GetByWhere(e => e.RecipientId.Equals(recipientId), true, e => e.CreateTime, SqlSugar.OrderByType.Desc)).First();
            var result = new GetLastEmailHistoryCodeInfoByRecipientIdResultDto();

            // 判断是否为空
            if (emailhistoryInfo == null)
            {
                result.Success    = false;
                result.ResultInfo = string.Format("【{0}】账号暂无邮件历史信息,请检查账号是否正确!如账号准确无误,请联系管理员。", recipientId);
                return(result);
            }
            ModelBindingService.CopyModel(result, emailhistoryInfo);
            // 判断是否过期(10分钟)
            if (emailhistoryInfo.CreateTime.AddMinutes(10) < DateTime.Now)
            {
                return(result = new GetLastEmailHistoryCodeInfoByRecipientIdResultDto
                {
                    RecipientId = recipientId,
                    Success = false,
                    ResultInfo = string.Format("【{0}】账号验证码已过期,请重新发送!", recipientId)
                });
            }
            return(result);
        }
        public async Task <GetLastEmailHistoryInfoByRecipientIdResultDto> GetLastEmailHistoryInfoByRecipientId(string recipientId)
        {
            var emailhistoryInfo = await _context.EmailHistoryInfo
                                   .Where(e => e.IsDeleted == 0)
                                   .OrderByDescending(e => e.CreateTime)
                                   .FirstOrDefaultAsync(e => e.RecipientId.Equals(recipientId));

            var result = new GetLastEmailHistoryInfoByRecipientIdResultDto();

            ModelBindingService.CopyModel(result.EmailHistoryInfo, emailhistoryInfo);
            // 判断是否为空
            if (emailhistoryInfo == null)
            {
                result.Success    = false;
                result.ResultInfo = string.Format("【{0}】账号暂无邮件历史信息,请检查账号是否正确!如账号准确无误,请联系管理员。", recipientId);
                return(result);
            }
            // 判断是否过期(10分钟)
            if (emailhistoryInfo.CreateTime.AddMinutes(10) < DateTime.Now)
            {
                result.Success          = false;
                result.ResultInfo       = string.Format("【{0}】账号验证码已过期,请重新发送!", recipientId);
                result.EmailHistoryInfo = null;
                return(result);
            }
            return(result);
        }
Beispiel #3
0
        public async Task <DevLoveInfoDto> GetDevLoveInfoByDLQQ(string dLQQ)
        {
            var devLoveInfo = await _context.DevLoveInfo
                              .Where(d => d.IsDeleted == 0)
                              .FirstOrDefaultAsync(d => d.DLQQ.Equals(dLQQ));

            return(ModelBindingService.CopyModel <DevLoveInfoDto, DevLoveInfo>(devLoveInfo));
        }
Beispiel #4
0
        public async Task <GetAllEmailHistoryResultDto> GetAllEmailHistoryInfoByRecipientId(string recipientId)
        {
            var listDto = await _context.GetByWhere(e => e.RecipientId.Equals(recipientId));

            return(new GetAllEmailHistoryResultDto()
            {
                ResultListDto = ModelBindingService.CopyModelList <EmailHistoryInfoDto, HW_EmailHistoryInfo>(listDto),
                Count = listDto.Count()
            });
        }
Beispiel #5
0
        public async Task <GetAllEmailHistoryResultDto> GetAllEmailHistoryInfo()
        {
            var listDto = await _context.GetAll();

            return(new GetAllEmailHistoryResultDto()
            {
                // 剔除创建时间和删除状态
                ResultListDto = ModelBindingService.CopyModelList <EmailHistoryInfoDto, HW_EmailHistoryInfo>(listDto),
                Count = listDto.Count()
            });
        }
Beispiel #6
0
        public async Task <GetAllDevLoveInfoResultDto> GetAllDevLoveInfo()
        {
            var listDto = await _context.DevLoveInfo
                          .Where(d => d.IsDeleted == 0)
                          .ToListAsync();

            return(new GetAllDevLoveInfoResultDto()
            {
                ResultListDto = ModelBindingService.CopyModelList <DevLoveInfoDto, DevLoveInfo>(listDto),
                Count = listDto.Count()
            });
        }
        public async Task <GetAllEmailHistoryResultDto> GetAllEmailHistoryInfo()
        {
            var listDto = await _context.EmailHistoryInfo
                          .Where(e => e.IsDeleted == 0)
                          .ToListAsync();

            return(new GetAllEmailHistoryResultDto()
            {
                // 剔除创建时间和删除状态
                ResultListDto = ModelBindingService.CopyModelList <EmailHistoryInfoDto, EmailHistoryInfo>(listDto),
                Count = listDto.Count()
            });
        }
        public async Task <ResultDto> AddPhoneReceiveInfo(List <AddPhoneReceiveInfoDto> modelList)
        {
            // 判断是否有未归还的手机
            var result = await GetPhoneReceiveInfoByUserId(modelList[0].ReceiveUserID);

            if (result.PhoneModelList.Count > 0)
            {
                // 当前用户领取手机未归还,请先归还再做处理。
                throw new Exception("The current user picks up the mobile phone and has not returned it. Please return it before processing.");
            }
            return(new ResultDto
            {
                Success =
                    await _context.AddRange(ModelBindingService.CopyModelList <HW_PhoneReceiveInfo, AddPhoneReceiveInfoDto>(modelList))
            });
        }
Beispiel #9
0
        public async Task <ResultDto> UpdateDevLoveInfo(UpdateDevLoveInfoDto updateDevLoveInfoDto)
        {
            // 查询出原有数据
            var devLoveInfo = await _context.DevLoveInfo
                              .FindAsync(updateDevLoveInfoDto.DLId);

            if (devLoveInfo != null)
            {
                // 该QQ账号没有绑定的信息
                throw new Exception("The QQ account has no binding information.");
            }
            ModelBindingService.CopyModel(devLoveInfo, updateDevLoveInfoDto);
            _context.DevLoveInfo.Update(devLoveInfo);
            return(new ResultDto()
            {
                Success = await _context.SaveChangesAsync() > 0 ? true : false
            });
        }
Beispiel #10
0
        public async Task <ResultDto> CreateDevLoveInfo(CreateDevLoveInfoDto createDevLoveInfoDto)
        {
            // 判断是否存在该QQ
            var devLoveInfo = await _context.DevLoveInfo
                              .Where(d => d.IsDeleted == 0)
                              .FirstOrDefaultAsync(d => d.DLQQ.Equals(createDevLoveInfoDto.DLQQ));

            if (devLoveInfo != null)
            {
                // 该QQ账号所绑定的信息已存在
                throw new Exception("The information bound to this QQ account already exists.");
            }
            ModelBindingService.CopyModel(devLoveInfo, createDevLoveInfoDto);
            await _context.DevLoveInfo.AddAsync(devLoveInfo);

            return(new ResultDto()
            {
                Success = await _context.SaveChangesAsync() > 0 ? true : false
            });
        }
Beispiel #11
0
        public async Task <ResultDto> CreateEmailHistoryInfo(createEmailHistoryInfoDto createEmailHistoryInfoDto)
        {
            // 检测邮箱账号为否为QQ邮箱,并且是否正确
            string expression = AppConfigurtaionService.Configuration["EmailServicesStrings:EmailExpression"]; // 拿到配置文件中的正则表达式

            if (!Regex.IsMatch(createEmailHistoryInfoDto.RecipientId, expression, RegexOptions.Compiled))
            {
                // 请输入正确的QQ邮箱账号
                throw new Exception("Please enter the correct QQ email account.");
            }
            var emailHistory = ModelBindingService.CopyModel <HW_EmailHistoryInfo, createEmailHistoryInfoDto>(createEmailHistoryInfoDto);

            // 发送QQ邮件
            if (createEmailHistoryInfoDto.IsSendEmail)
            {
                emailHistory.EmailBody = _emailServices.SendRandomCodeQQEmail(emailHistory.RecipientId).RecipientBody;
            }
            return(new ResultDto()
            {
                Success = await _context.Add(emailHistory)
            });
        }