public async Task CreateAccountAsync(Account account, string name, string phoneNumber, string cardName) { var accounts = await _accountRepository.ListAccountsNumbers(); var number = _accountHelper.GenerateIban(); while (accounts.Contains(number)) { number = _accountHelper.GenerateIban(); } account.Number = number; var cards = await _cardRepository.ListCardsNumber(); var cardNumber = _cardHelper.Generate16DigitNumber(); while (cards.Contains(_cryptoHelper.Hash(cardNumber))) { cardNumber = _cardHelper.Generate16DigitNumber(); } var securityCode = _cardHelper.Generate3DigitSecurityCode(); var pinCode = _cardHelper.GeneratePinCode(); var card = new Card { Id = new Guid(), Number = _cryptoHelper.Hash(cardNumber), Last4Digits = cardNumber.Substring(12), SecurityCode = _cryptoHelper.Hash(securityCode), PinCode = _cryptoHelper.Hash(pinCode), ExpireTime = DateTime.Now.AddYears(3), Name = string.IsNullOrEmpty(cardName) ? "Card Name" : cardName, CardHolderName = name, StatusId = 1, AccountId = account.Id }; account.Cards.Add(card); await _smsService.SendAsync(phoneNumber, $"Do not share your data with anyone\nCard Number: {cardNumber}\nName: {card.CardHolderName}\nExpiration date: {card.ExpireTime}\nCVV: {securityCode}\nPin-Code: {pinCode}"); await _accountRepository.Add(account); }