public string CreateVirtualWallet([FromBody] AccountHolderInformation accountHolderInformation, int merchantAccountID, String apiKey) { VirtualWalletTestAPI wallet = new VirtualWalletTestAPI(); myDBCommand.Parameters.Clear(); myDBCommand.CommandType = CommandType.StoredProcedure; myDBCommand.CommandText = "tp_CheckForAPIKeyAndMerchantAccountID"; myDBCommand.Parameters.AddWithValue("@theAPIKey", apiKey); myDBCommand.Parameters.AddWithValue("@theMerchantAccountID", merchantAccountID); DataSet selectedAPIKey = myDBConnect.GetDataSetUsingCmdObj(myDBCommand); //check if APIKey exists if (selectedAPIKey != null && selectedAPIKey.Tables.Count > 0 && selectedAPIKey.Tables[0].Rows.Count > 0) { myDBCommand.CommandType = CommandType.StoredProcedure; myDBCommand.Parameters.Clear(); myDBCommand.CommandText = "tp_CreateVirtualWallet"; myDBCommand.Parameters.AddWithValue("@theEmail", accountHolderInformation.Email); myDBCommand.Parameters.AddWithValue("@theCardType", accountHolderInformation.CardType); myDBCommand.Parameters.AddWithValue("@theAccountNumber", accountHolderInformation.AccountNumber); //SqlParameter outputParameter = new SqlParameter("@theVirtualWalletID", 0); myDBCommand.Parameters.Add("@theVirtualWalletID", SqlDbType.Int).Direction = ParameterDirection.Output; //outputParameter.Direction = ParameterDirection.Output; //myDBCommand.Parameters.Add(outputParameter); myDBConnect.DoUpdateUsingCmdObj(myDBCommand); int id = Convert.ToInt32(myDBCommand.Parameters["@theVirtualWalletID"].Value); return("true"); } return("API Key and Merchant Account ID do not match"); }
public string UpdatePaymentAccount([FromBody] AccountHolderInformation accountHolderInformation, int merchantAccountID, String apiKey) { myDBCommand.Parameters.Clear(); myDBCommand.CommandType = CommandType.StoredProcedure; myDBCommand.CommandText = "tp_CheckForAPIKeyAndMerchantAccountID"; myDBCommand.Parameters.AddWithValue("@theAPIKey", apiKey); myDBCommand.Parameters.AddWithValue("@theMerchantAccountID", merchantAccountID); DataSet selectedAPIKey = myDBConnect.GetDataSetUsingCmdObj(myDBCommand); //check if APIKey exists if (selectedAPIKey != null && selectedAPIKey.Tables.Count > 0 && selectedAPIKey.Tables[0].Rows.Count > 0) { //first get users id using their email myDBCommand.Parameters.Clear(); myDBCommand.CommandType = CommandType.StoredProcedure; myDBCommand.CommandText = "tp_GetVirtualWalletIDByEmail"; myDBCommand.Parameters.AddWithValue("@theEmail", accountHolderInformation.Email); DataSet virtualWalletID = myDBConnect.GetDataSetUsingCmdObj(myDBCommand); DataTable virtualWalletIDTable = virtualWalletID.Tables[0]; int usersVirtualWalletID = 0; for (int i = 0; i < virtualWalletIDTable.Rows.Count; i++) { DataRow transRows = virtualWalletIDTable.Rows[i]; usersVirtualWalletID = Convert.ToInt32(transRows["VirtualWalletID"].ToString()); } myDBCommand.Parameters.Clear(); myDBCommand.CommandType = CommandType.StoredProcedure; myDBCommand.CommandText = "tp_UpdatePaymentAccount"; myDBCommand.Parameters.AddWithValue("@theVirtualWalletID", usersVirtualWalletID); myDBCommand.Parameters.AddWithValue("@theEmail", accountHolderInformation.Email); myDBCommand.Parameters.AddWithValue("@theCardType", accountHolderInformation.CardType); myDBCommand.Parameters.AddWithValue("@theAccountNumber", accountHolderInformation.AccountNumber); myDBConnect.DoUpdateUsingCmdObj(myDBCommand); return("true"); } return("API Key and Merchant Account ID do not match"); }