public static Gateway Load(Guid gatewayID) { Gateway gateway = new Gateway(); DbCommand cmd = SqlHelpers.CreateCommand(DataHelpers.ConnectionString, "dbo.ctx_GET_GATEWAY"); cmd.AddInputParam("pGatewayID", DbType.Guid, gatewayID); DataTable table = cmd.ExecuteSelectTable(); if ((table != null) && (table.Rows.Count > 0)) { gateway = table.Rows[0].ToGateway(); } return gateway; }
public static void Insert(Gateway gateway) { DbCommand cmd = SqlHelpers.CreateCommand(DataHelpers.ConnectionString, "dbo.ctx_INSERT_GATEWAY"); cmd.AddInputParam("pName", DbType.String, gateway.Name); cmd.AddInputParam("pGatewayTypeId", DbType.Guid, gateway.GatewayTypeID); cmd.AddInputParam("pChargebackFee", DbType.Currency, gateway.ChargebackFee); cmd.AddInputParam("pTransactionFee", DbType.Currency, gateway.TransactionFee); cmd.AddInputParam("pLoginID", DbType.String, gateway.LoginKey); cmd.AddInputParam("pPassword", DbType.String, gateway.PasswordKey); cmd.AddInputParam("pTransactionKey", DbType.String, gateway.TransactionKey); cmd.AddOutputParam("oGateway", DbType.Guid); SqlHelpers.ExecuteNonQuery(cmd); gateway.ID = cmd.ExtractGuid("oGateway"); }
public static Gateway ToGateway(this DataRow dr) { Gateway gateway = new Gateway(); gateway.ID = dr.GetGuid("Id"); gateway.GatewayTypeID = dr.GetGuid("GatewayTypeId"); gateway.Name = dr.GetString("Name"); gateway.ProviderName = dr.GetString("ProviderName"); gateway.FriendlyName = dr.GetString("FriendlyName"); gateway.ChargebackFee = dr.GetDouble("ChargebackFee"); gateway.TransactionFee = dr.GetDouble("TransactionFee"); gateway.LoginKey = dr.GetString("LoginID"); gateway.PasswordKey = dr.GetString("Password"); gateway.TransactionKey = dr.GetString("TransactionKey"); gateway.LastEditDate = dr.GetDate("LastEditDate"); gateway.CreationDate = dr.GetDate("CreationDate"); return gateway; }
public static Gateway Save(Gateway gateway) { DbCommand cmd = SqlHelpers.CreateCommand(DataHelpers.ConnectionString, "dbo.ctx_SAVE_GATEWAY"); cmd.AddInputOutputParam("pGatewayID", DbType.Guid, gateway.ID); cmd.AddInputOutputParam("pGatewayTypeId", DbType.Guid, gateway.GatewayTypeID); cmd.AddInputOutputParam("pName", DbType.String, gateway.Name); cmd.AddInputOutputParam("pProviderName", DbType.String, gateway.ProviderName); cmd.AddInputOutputParam("pFriendlyName", DbType.String, gateway.FriendlyName); cmd.AddInputOutputParam("pChargebackFee", DbType.Currency, gateway.ChargebackFee); cmd.AddInputOutputParam("pTransactionFee", DbType.Currency, gateway.TransactionFee); cmd.AddInputOutputParam("pLoginID", DbType.String, gateway.LoginKey); cmd.AddInputOutputParam("pPassword", DbType.String, gateway.PasswordKey); cmd.AddInputOutputParam("pTransactionKey", DbType.String, gateway.TransactionKey); cmd.AddOutputParam("oCreationDate", DbType.DateTime); cmd.AddOutputParam("oLastEditDate", DbType.DateTime); SqlHelpers.ExecuteNonQuery(cmd); gateway.ID = cmd.ExtractGuid("pGatewayID"); gateway.GatewayTypeID = cmd.ExtractGuid("pGatewayTypeId"); gateway.Name = cmd.ExtractString("pName"); gateway.ProviderName = cmd.ExtractString("pProviderName"); gateway.FriendlyName = cmd.ExtractString("pFriendlyName"); gateway.ChargebackFee = cmd.ExtractDouble("pChargebackFee"); gateway.TransactionFee = cmd.ExtractDouble("pTransactionFee"); gateway.LoginKey = cmd.ExtractString("pLoginID"); gateway.PasswordKey = cmd.ExtractString("pPassword"); gateway.TransactionKey = cmd.ExtractString("pTransactionKey"); gateway.CreationDate = cmd.ExtractDateTime("oCreationDate"); gateway.LastEditDate = cmd.ExtractDateTime("oLastEditDate"); return gateway; }