Ejemplo n.º 1
0
        public async Task <bool> CreateAsync(Customer customer)
        {
            var isExsits = _accountRepository.IsEmailExistsAsync(customer.Email);

            if (isExsits.Result == false)
            {
                customer.PasswordSalt = Hashing.GetSalt();
                customer.PasswordHash = Hashing.GenerateHash(customer.Password, customer.PasswordSalt);
                var isCreated = await _accountRepository.CreateAccountAsync(customer);

                if (isCreated == false)
                {
                    throw new Exception("Creation failed");
                }
                EmailVerification emailVerification = new EmailVerification()
                {
                    Email            = customer.Email,
                    VerificationCode = GenerateRandomNo(1000, 9999),
                    ExpirationTime   = DateTime.Now.AddMinutes(60)
                };
                await _verificationRepository.CreateEmailVerificationAsync(emailVerification);

                await _verificationService.SendVerificationCodeAsync(emailVerification);

                return(true);
            }
            return(false);
        }
 public async Task SaveVerificationcode(EmailVerification emailVerification)
 {
     await _verificationRepository.CreateEmailVerificationAsync(emailVerification);
 }