コード例 #1
0
        public async Task <ResultMessage <bool> > GenerateRegistrationEmail(RegisterFormDTO registerFormDTO)
        {
            RegistrationDTO regDTO = Mapping.Mapper.Map <RegistrationDTO>(registerFormDTO);

            regDTO.RegistrationCode = GenerateRegistrationCode();
            regDTO.Used             = false;
            regDTO.Timestamp        = DateTime.Now;

            ResultMessage <RegistrationDTO> registrationProcessResult = await _registrationService.Add(regDTO);

            if (!registrationProcessResult.IsSuccess)
            {
                return(new ResultMessage <bool>(registrationProcessResult.Status, registrationProcessResult.Message));
            }

            await _emailSender.SendTemplateEmailAsync(
                new TemplateEmail
            {
                From         = _fromEmailAddress,
                To           = registerFormDTO.Email,
                TemplateId   = _regEmailTemplateId,
                TemplateData = new
                {
                    reg_link     = GenerateRegistrationLink(regDTO.RegistrationCode),
                    first_name   = registerFormDTO.FirstName,
                    last_name    = registerFormDTO.LastName,
                    index_number = registerFormDTO.Index
                },
            });

            return(new ResultMessage <bool>(true));
        }