예제 #1
0
        public static List <CardProfileModel> GetCardProfiles()
        {
            try
            {
                var returnedCardProfiles = new List <CardProfileModel>();

                var cardProfiles = CardProfileDL.RetrieveCardProfiles();

                foreach (CardProfile cardProfile in cardProfiles)
                {
                    var cardProfileObj = new CardProfileModel
                    {
                        ID         = cardProfile.ID,
                        Name       = cardProfile.Name,
                        CardType   = cardProfile.CardType,
                        CardBin    = cardProfile.CardBin,
                        CEDuration = Convert.ToInt64(cardProfile.CEDuration),
                    };

                    returnedCardProfiles.Add(cardProfileObj);
                }

                return(returnedCardProfiles);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        public static List <Object> RetrieveCardProfiles()
        {
            try
            {
                var returnedCardProfiles = new List <object>();

                var cardProfiles = CardProfileDL.RetrieveCardProfiles();

                foreach (CardProfile cardProfile in cardProfiles)
                {
                    Object cardProfileObj = new
                    {
                        ID         = cardProfile.ID,
                        Name       = cardProfile.Name,
                        CardType   = cardProfile.CardType,
                        CardBin    = cardProfile.CardBin,
                        CEDuration = cardProfile.CEDuration,
                    };

                    returnedCardProfiles.Add(cardProfileObj);
                }

                return(returnedCardProfiles);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
 public static bool Update(CardProfile cardProfile)
 {
     try
     {
         return(CardProfileDL.Update(cardProfile));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #4
0
        public Card ProduceCard(long cardProfileID, long requestingBranch)
        {
            try
            {
                var card = new Card();

                DateTime currentDate            = DateTime.Now;
                Random   randomizer             = new Random();
                var      cardProfile            = CardProfileDL.RetrieveCardProfileByID(cardProfileID);
                string   CompleteCardProfileBIN = cardProfile.CardBin;
                string   cardType  = cardProfile.CardType;
                var      panlength = 0;

                if (cardType == StatusUtil.CardType.VerveCard.ToString())
                {
                    panlength = 19;
                }
                else if (cardType == StatusUtil.CardType.MasterCard.ToString() || cardType == StatusUtil.CardType.VISA.ToString())
                {
                    panlength = 16;
                }

                int    randomNumberLength = (panlength - 1) - CompleteCardProfileBIN.Length;
                string randNumber         = string.Empty;
                if (randomNumberLength <= 9)
                {
                    randNumber += randomizer.Next(Convert.ToInt32(Math.Pow(10, (double)randomNumberLength))).ToString();
                }
                else
                {
                    randNumber += randomizer.Next(Convert.ToInt32(Math.Pow(10, (double)randomNumberLength - 9))).ToString();
                    randNumber += randomizer.Next(Convert.ToInt32(Math.Pow(10, 9))).ToString();
                }

                //Generate new Card PAN
                string newCardPAN = string.Format("{0}{1}", CompleteCardProfileBIN, randNumber.PadLeft(randomNumberLength, '0'));
                //Get Luhn Digit
                string pan = string.Format("{0}{1}", newCardPAN, GetLuhnAlgorithmNumber(newCardPAN));
                //Get Luhn Digit

                card.CardPan          = Crypter.Encrypt(System.Configuration.ConfigurationManager.AppSettings.Get("ekey"), pan);
                card.HashedCardPan    = PasswordHash.MD5Hash(pan);
                card.CardProfileID    = cardProfile.ID;
                card.RequestingBranch = requestingBranch;
                card.Date             = System.DateTime.Now;
                card.CardExpiryDate   = new DateTime(currentDate.Year, currentDate.Month, 1).AddMonths(Convert.ToInt32(cardProfile.CEDuration));

                return(card);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #5
0
 public static bool Save(CardProfile cardProfile, out string message)
 {
     try
     {
         if (CardProfileDL.CardProfileExists(cardProfile))
         {
             message = string.Format("Card profile with name: {0} exists already", cardProfile.Name);
             return(false);
         }
         else
         {
             message = string.Empty;
             return(CardProfileDL.Save(cardProfile));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }