public override List <ICardDetails> Select() { Source = "sp_FetchCardDetails "; try { Object[] param = { new MySqlParameter("@paramToken", UserProfileObj.GetToken()) }; DataSet Output = Commands.ExecuteQuery(Source, CommandType.StoredProcedure, param); List <ICardDetails> CardDetail = new List <ICardDetails>(); foreach (DataRow dr in Output.Tables[0].Rows) { ICardDetails CardObj = new CardDetails(); CardObj.SetCardID(Int32.Parse(dr["caID"].ToString())); CardObj.SetName(dr["CardNameEncrypt"].ToString()); CardObj.SetCardNumber(dr["CardNumberEncrypt"].ToString()); CardObj.SetExpiryMonth(dr["ExpiryMonthEncrypt"].ToString()); CardObj.SetExpiryYear((dr["ExpiryYearEncrypt"].ToString())); CardObj.SetCvv((dr["CvvEncrypt"].ToString())); CardObj.SetIV(dr["Salt"].ToString()); CardObj.SetDecryptionKey(dr["DecryptionKey"].ToString()); CardDetail.Add(CardObj); } return(CardDetail); } catch (Exception ex) { Logger.Instance().Log(Fatal.Instance(), ex); throw ex; } }
public override List <ICardDetails> Select() { try { bool Response = new Security(UserProfileObj).AuthenticateUser(); if (Response == true) { List <ICardDetails> DecryptedCardDetailsList = new List <ICardDetails>(); foreach (ICardDetails EncryptedCardObj in CardDetailsDataLayerObj.Select()) { ICardDetails DecryptedCardDetails = new CardDetails(); AESObj.SetIV(EncryptedCardObj.GetIV()); AESObj.SetKey(EncryptedCardObj.GetDecryptionKey()); DecryptedCardDetails.SetCardID(EncryptedCardObj.GetCardID()); DecryptedCardDetails.SetName(AESObj.Decrypt(EncryptedCardObj.GetName())); DecryptedCardDetails.SetCardNumber(AESObj.Decrypt(EncryptedCardObj.GetCardNumber()).ToString()); DecryptedCardDetails.SetExpiryMonth(AESObj.Decrypt(EncryptedCardObj.GetExpiryMonth())); DecryptedCardDetails.SetExpiryYear(AESObj.Decrypt(EncryptedCardObj.GetExpiryYear())); DecryptedCardDetails.SetCvv(AESObj.Decrypt(EncryptedCardObj.GetCvv())); DecryptedCardDetailsList.Add(DecryptedCardDetails); } return(DecryptedCardDetailsList); } else { return(null); } } catch (NullReferenceException nex) { Logger.Instance().Log(Warn.Instance(), new LogInfo("Received null reference while fetching card details (Routine : AuthenticateUser), might be token manipulation. Check token : " + UserProfileObj.GetToken())); throw nex; } catch (Exception ex) { Logger.Instance().Log(Fatal.Instance(), ex); throw ex; } }