コード例 #1
0
ファイル: CardService.cs プロジェクト: DimitriDondoladze/BBS
        public async Task GenerateCard(Account account, string type)
        {
            _logger.Info($"Genereated Card by name: {account.Name}");
            string cardIdentifier = GenerationHelper.GenerateIdentifier();
            int    timeSpan       = PropertyHelper.ValidSpanYears;
            string initialStatus  = PropertyHelper.InitialStatus;
            int    cvc2           = GenerationHelper.GenerateCvc();

            if (!_cardRepository.ValidateIdentifier(cardIdentifier))
            {
                await GenerateCard(account, type);
            }

            string bankIdentifier     = _accountPropertyRepository.GetPropertyModel().BankIdentificationNumber;
            string industryIdentifier = _accountPropertyRepository.GetPropertyModel().MajorIndustryIdentifier;
            string partialCardNumber  = industryIdentifier + bankIdentifier + account.Number + cardIdentifier;

            string checksum = GenerationHelper.GenerateChecksum(partialCardNumber);

            string cardNumber = partialCardNumber + checksum;

            Card card = new Card()
            {
                Name = type, AccountId = account.Id, IsDefault = true, UserId = account.UserId, Number = cardNumber, RegDate = DateTime.Now, ExpDate = DateTime.Now.AddYears(timeSpan), Status = initialStatus, Cvc2 = cvc2
            };

            await _cardRepository.InsertAsync(card);

            await _cardRepository.SaveAsync();
        }
コード例 #2
0
 protected override void Given()
 {
     cardNumber       = "521746983254187";
     expectedChecksum = "3";
     actualChecksum   = GenerationHelper.GenerateChecksum(cardNumber);
 }