Пример #1
0
        public void Can_Insert_New_CardAccount()
        {
            var user = Context.Set<User>().FirstOrDefault(x => x.UserName == "terminator");
            var vendor = Context.Set<CardVendor>().Find("visa");
            var currency = Context.Set<Currency>().Find("USD");

            var card = new Card("1232123413241234", vendor, "TEST", "TEST", DateTime.Today.AddDays(300));
            var userCard = new UserCard(card, user, new CardSettings(card.Id, new CardLimits()));

            Context.Set<UserCard>().Add(userCard);

            var account = new CardAccount("1234567890123", currency, user) {ExpirationDateUtc = DateTime.UtcNow.AddDays(300)};

            Context.Set<CardAccount>().Add(account);
            Context.SaveChanges();
        }
Пример #2
0
        public void Can_Insert_MultipleCards_With_Account()
        {
            var user = Context.Set<User>().FirstOrDefault(x => x.UserName == "terminator");
            var vendor = Context.Set<CardVendor>().Find("visa");
            var currency = Context.Set<Currency>().Find("USD");

            var card1 = new Card("2232123413241234", vendor, "TEST", "TEST", DateTime.Today.AddDays(300));
            var userCard1 = new UserCard(card1, user, new CardSettings(card1.Id, new CardLimits()));
            var card2 = new Card("3232123413241234", vendor, "TEST", "TEST", DateTime.Today.AddDays(300));
            var userCard2 = new UserCard(card2, user, new CardSettings(card2.Id, new CardLimits()));

            Context.Set<UserCard>().Add(userCard1);
            Context.Set<UserCard>().Add(userCard2);

            var account1 = new CardAccount("1234567891234", currency, user) { ExpirationDateUtc = DateTime.UtcNow.AddDays(300) };
            account1.Cards.Add(userCard2);
            Context.Set<CardAccount>().Add(account1);

            Context.SaveChanges();
        }
Пример #3
0
        public CardAccount Create(Currency currency, User owner, DateTime expirationDateUtc)
        {
            Argument.NotNull(currency, "currency");
            Argument.NotNull(owner, "owner");

            string accountNo;
            while (true)
            {
                accountNo = GenerateAccountNo();
                var existingAccount = _cardAccountRepository.Find(accountNo);
                if (existingAccount == null)
                {
                    break;
                }
            }
            var account = new CardAccount(accountNo, currency, owner)
            {
                ExpirationDateUtc = expirationDateUtc
            };
            return account;
        }
Пример #4
0
        public UserCard Create(
            CardAccount cardAccount,
            CardVendor cardVendor,
            User cardOwner,
            string cardholderFirstName,
            string cardholderLastName,
            DateTime expirationDateUtc)
        {
            Argument.NotNull(cardAccount, "cardAccount");
            Argument.NotNull(cardVendor, "cardVendor");
            Argument.NotNull(cardOwner, "cardOwner");

            var card = _cardFactory.Create(
                cardVendor,
                cardholderFirstName,
                cardholderLastName,
                expirationDateUtc);
            var settings = new CardSettings(card.Id, _cardLimitsFactory.CreateDefault(cardAccount.Currency));
            var userCard = new UserCard(cardAccount, card, cardOwner, settings);
            return userCard;
        }
Пример #5
0
 internal UserCard(CardAccount account, Card card, User owner, CardSettings settings)
     : this(card, owner, settings)
 {
     Argument.NotNull(account, "cardAccount");
     Account = account;
 }
Пример #6
0
 internal UserCard(CardAccount account, Card card, User owner, CardSettings settings)
     : this(card, owner, settings)
 {
     Argument.NotNull(account, "cardAccount");
     Account = account;
 }