Esempio n. 1
0
    /// <summary>
    /// Action to generate Credit Card Number.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnGenerate_Click(object sender, EventArgs e)
    {
        ICardNumberGenerator cardNumberGenerator = CardNumberGenerator.Instance;

        int    index    = dlCardName.SelectedIndex;
        string cardName = dlCardName.SelectedValue;

        txtCard.Text = cardNumberGenerator.GenerateCardNumber(cardName.Trim().Replace(" ", ""));
    }
Esempio n. 2
0
        public CardAccount ProvisionCardAccount(string ownerId, double amount)
        {
            var cardAccount = applicationDbContext
                              .CardAccounts
                              .FirstOrDefault(x => !x.HasMoney);

            if (cardAccount is null)
            {
                return(CreateAccount(ownerId, amount));
            }
            else
            {
                var cardNumber = numberGenerator.GenerateCardNumber();
                cardAccount.EmitCardNumber(ownerId, amount, cardNumber);

                applicationDbContext.SaveChanges();

                return(cardAccount);
            }
        }