Beispiel #1
0
        public IActionResult Add(AddCreditCardDto addCreditCardDto)
        {
            var result = _creditCardService.Add(addCreditCardDto, addCreditCardDto.CardNumber, addCreditCardDto.ExpirationDate, addCreditCardDto.Cvv);

            if (result.Success)
            {
                return(Ok(result));
            }
            return(BadRequest(result));
        }
        public IDataResult <FromBankCreditCard> Add(AddCreditCardDto addCreditCardDto, string cardNumber, string expirationDate, string cvv)
        {
            byte[] cardNumberHash, cardNumberSalt, expirationDateHash, expirationDateSalt, cvvHash, cvvSalt;

            HashingHelper.CreateCardNumberHash(cardNumber, out cardNumberHash, out cardNumberSalt);
            HashingHelper.CreateExpirationDateHash(expirationDate, out expirationDateHash, out expirationDateSalt);
            HashingHelper.CreateCvvHash(cvv, out cvvHash, out cvvSalt);

            var card = new FromBankCreditCard
            {
                Id                 = addCreditCardDto.Id,
                UserId             = addCreditCardDto.UserId,
                CardNumberHash     = cardNumberHash,
                CardNumberSalt     = cardNumberSalt,
                CvvHash            = cvvHash,
                CvvSalt            = cvvSalt,
                ExpirationDateHash = expirationDateHash,
                ExpirationDateSalt = expirationDateSalt
            };

            _creditCardDal.Add(card);
            return(new SuccessDataResult <FromBankCreditCard>(card, "Eklendi"));
        }