Esempio n. 1
0
        public static PaymentGateway Load(Int32 paymentGatewayId, bool useCache)
        {
            if (paymentGatewayId == 0)
            {
                return(null);
            }
            PaymentGateway paymentGateway = null;
            string         key            = "PaymentGateway_" + paymentGatewayId.ToString();

            if (useCache)
            {
                paymentGateway = ContextCache.GetObject(key) as PaymentGateway;
                if (paymentGateway != null)
                {
                    return(paymentGateway);
                }
            }
            paymentGateway = new PaymentGateway();
            if (paymentGateway.Load(paymentGatewayId))
            {
                if (useCache)
                {
                    ContextCache.SetObject(key, paymentGateway);
                }
                return(paymentGateway);
            }
            return(null);
        }
Esempio n. 2
0
        public static bool Delete(Int32 paymentGatewayId)
        {
            PaymentGateway paymentGateway = new PaymentGateway();

            if (paymentGateway.Load(paymentGatewayId))
            {
                return(paymentGateway.Delete());
            }
            return(false);
        }
 /// <summary>
 /// Loads the given PaymentGateway object from the given database data reader.
 /// </summary>
 /// <param name="paymentGateway">The PaymentGateway object to load.</param>
 /// <param name="dr">The database data reader to read data from.</param>
 public static void LoadDataReader(PaymentGateway paymentGateway, IDataReader dr)
 {
     //SET FIELDS FROM ROW DATA
     paymentGateway.PaymentGatewayId = dr.GetInt32(0);
     paymentGateway.StoreId          = dr.GetInt32(1);
     paymentGateway.Name             = dr.GetString(2);
     paymentGateway.ClassId          = dr.GetString(3);
     paymentGateway.ConfigData       = NullableData.GetString(dr, 4);
     paymentGateway.ReCrypt          = dr.GetBoolean(5);
     paymentGateway.IsDirty          = false;
 }
Esempio n. 4
0
        public static PaymentGatewayCollection LoadForStore(int maximumRows, int startRowIndex, string sortExpression)
        {
            int storeId = Token.Instance.StoreId;
            //CREATE THE DYNAMIC SQL TO LOAD OBJECT
            StringBuilder selectQuery = new StringBuilder();

            selectQuery.Append("SELECT");
            if (maximumRows > 0)
            {
                selectQuery.Append(" TOP " + (startRowIndex + maximumRows).ToString());
            }
            selectQuery.Append(" " + PaymentGateway.GetColumnNames(string.Empty));
            selectQuery.Append(" FROM ac_PaymentGateways");
            selectQuery.Append(" WHERE StoreId = @storeId");
            if (!string.IsNullOrEmpty(sortExpression))
            {
                selectQuery.Append(" ORDER BY " + sortExpression);
            }
            Database  database      = Token.Instance.Database;
            DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString());

            database.AddInParameter(selectCommand, "@storeId", System.Data.DbType.Int32, storeId);
            //EXECUTE THE COMMAND
            PaymentGatewayCollection results = new PaymentGatewayCollection();
            int thisIndex = 0;
            int rowCount  = 0;

            using (IDataReader dr = database.ExecuteReader(selectCommand))
            {
                while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows)))
                {
                    if (thisIndex >= startRowIndex)
                    {
                        PaymentGateway paymentGateway = new PaymentGateway();
                        PaymentGateway.LoadDataReader(paymentGateway, dr);
                        results.Add(paymentGateway);
                        rowCount++;
                    }
                    thisIndex++;
                }
                dr.Close();
            }
            return(results);
        }
Esempio n. 5
0
 public static SaveResult Insert(PaymentGateway paymentGateway)
 {
     return(paymentGateway.Save());
 }
Esempio n. 6
0
 public static SaveResult Update(PaymentGateway paymentGateway)
 {
     return(paymentGateway.Save());
 }
Esempio n. 7
0
 public static bool Delete(PaymentGateway paymentGateway)
 {
     return(paymentGateway.Delete());
 }