コード例 #1
0
        public static SubscriptionPlan Load(Int32 productId, bool useCache)
        {
            if (productId == 0)
            {
                return(null);
            }
            SubscriptionPlan subscriptionPlan = null;
            string           key = "SubscriptionPlan_" + productId.ToString();

            if (useCache)
            {
                subscriptionPlan = ContextCache.GetObject(key) as SubscriptionPlan;
                if (subscriptionPlan != null)
                {
                    return(subscriptionPlan);
                }
            }
            subscriptionPlan = new SubscriptionPlan();
            if (subscriptionPlan.Load(productId))
            {
                if (useCache)
                {
                    ContextCache.SetObject(key, subscriptionPlan);
                }
                return(subscriptionPlan);
            }
            return(null);
        }
コード例 #2
0
        public static bool Delete(Int32 productId)
        {
            SubscriptionPlan subscriptionPlan = new SubscriptionPlan();

            if (subscriptionPlan.Load(productId))
            {
                return(subscriptionPlan.Delete());
            }
            return(false);
        }
コード例 #3
0
 /// <summary>
 /// Loads the given SubscriptionPlan object from the given database data reader.
 /// </summary>
 /// <param name="subscriptionPlan">The SubscriptionPlan object to load.</param>
 /// <param name="dr">The database data reader to read data from.</param>
 public static void LoadDataReader(SubscriptionPlan subscriptionPlan, IDataReader dr)
 {
     //SET FIELDS FROM ROW DATA
     subscriptionPlan.ProductId                = dr.GetInt32(0);
     subscriptionPlan.Name                     = dr.GetString(1);
     subscriptionPlan.NumberOfPayments         = dr.GetInt16(2);
     subscriptionPlan.PaymentFrequency         = dr.GetInt16(3);
     subscriptionPlan.PaymentFrequencyUnitId   = dr.GetByte(4);
     subscriptionPlan.RecurringCharge          = dr.GetDecimal(5);
     subscriptionPlan.RecurringChargeSpecified = dr.GetBoolean(6);
     subscriptionPlan.GroupId                  = NullableData.GetInt32(dr, 7);
     subscriptionPlan.TaxCodeId                = NullableData.GetInt32(dr, 8);
     subscriptionPlan.IsDirty                  = false;
 }
コード例 #4
0
        public static SubscriptionPlanCollection LoadForTaxCode(Int32 taxCodeId, int maximumRows, int startRowIndex, string sortExpression)
        {
            //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(" " + SubscriptionPlan.GetColumnNames(string.Empty));
            selectQuery.Append(" FROM ac_SubscriptionPlans");
            selectQuery.Append(" WHERE TaxCodeId = @taxCodeId");
            if (!string.IsNullOrEmpty(sortExpression))
            {
                selectQuery.Append(" ORDER BY " + sortExpression);
            }
            Database  database      = Token.Instance.Database;
            DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString());

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

            using (IDataReader dr = database.ExecuteReader(selectCommand))
            {
                while (dr.Read() && ((maximumRows < 1) || (rowCount < maximumRows)))
                {
                    if (thisIndex >= startRowIndex)
                    {
                        SubscriptionPlan subscriptionPlan = new SubscriptionPlan();
                        SubscriptionPlan.LoadDataReader(subscriptionPlan, dr);
                        results.Add(subscriptionPlan);
                        rowCount++;
                    }
                    thisIndex++;
                }
                dr.Close();
            }
            return(results);
        }
コード例 #5
0
 public static SaveResult Insert(SubscriptionPlan subscriptionPlan)
 {
     return(subscriptionPlan.Save());
 }
コード例 #6
0
 public static SaveResult Update(SubscriptionPlan subscriptionPlan)
 {
     return(subscriptionPlan.Save());
 }
コード例 #7
0
 public static bool Delete(SubscriptionPlan subscriptionPlan)
 {
     return(subscriptionPlan.Delete());
 }
コード例 #8
0
ファイル: Product.cs プロジェクト: phongdevelopers/my-phong
        /// <summary>
        /// Copies the product to the specified category.
        /// </summary>
        /// <param name="categoryId">if ZERO then will copy the product with the categories as the orignal product have </param>
        /// <param name="copyName">Name to use for the copied product</param>
        public void SaveCopy(int categoryId, string copyName)
        {
            if (string.IsNullOrEmpty(copyName))
            {
                this.Name = "Copy of " + this.Name;
            }
            else
            {
                this.Name = copyName;
            }
            CopyChildren();
            //make sure related products and upsell products
            //are loaded before resetting product id to 0
            RelatedProductCollection         relatedProds            = this.RelatedProducts;
            UpsellProductCollection          upsellProds             = this.UpsellProducts;
            SubscriptionPlan                 subplan                 = this.SubscriptionPlan;
            ProductProductTemplateCollection productProductTemplates = this.ProductProductTemplates;

            // KEEP THE ORIGNAL PRODUCTS CATEGORIES IN A NEW LIST
            List <int> pcats = new List <int>();

            pcats.AddRange(this.Categories);

            this.ProductId = 0;
            this.Save();

            // RELOAD THE LIST, SO THAT IT CAN PROPERLY BE SAVED
            // THIS IS FOR PRODUCTS WE ARE COPYING WITH FULL CATEGORY DETAILS
            this.Categories.Load(this.ProductId);

            if (categoryId > 0)
            {
                this.Categories.Add(categoryId);
            }
            else
            {
                this.Categories.AddRange(pcats);
            }
            this.Categories.ProductId = this.ProductId;

            this.Categories.Save();

            foreach (RelatedProduct prod in relatedProds)
            {
                prod.ProductId = this.ProductId;
                prod.Save();
            }

            foreach (UpsellProduct upsell in upsellProds)
            {
                upsell.ProductId = this.ProductId;
                upsell.Save();
            }
            if (subplan != null)
            {
                subplan.ProductId = this.ProductId;
                subplan.Save();
            }
            foreach (ProductProductTemplate productProductTemplate in productProductTemplates)
            {
                productProductTemplate.ProductId = this.ProductId;
                productProductTemplate.Save();
            }
        }