Esempio n. 1
0
        public static BankAccount CreateBankAccount(string owner, bool createCard = true)
        {
            var pvvCode           = VerificationValuesHandler.GeneratePvvCode();
            var pvvHash           = VerificationValuesHandler.GetPvvHash(pvvCode);
            var cardNumber        = VerificationValuesHandler.GenerateCardNumber();
            var bankAccountNumber = VerificationValuesHandler.GenerateBankAccountNumber();
            var cvvHash           = VerificationValuesHandler.GetCvvHash(cardNumber, bankAccountNumber);

            var bankAccount = new BankAccount()
            {
                BankAccountNumber = bankAccountNumber,
                CardNumber        = cardNumber,
                PvvHash           = pvvHash,
                CvvHash           = cvvHash,
                Owner             = owner,
                Value             = 0
            };

            using ApplicationContext db = new ApplicationContext();
            db.AddBankAccountAsync(bankAccount);

            if (createCard)
            {
                CreateCard(cardNumber, bankAccountNumber, pvvCode, cvvHash, owner);
            }

            return(bankAccount);
        }