/// <summary>
        /// Updates the discount
        /// </summary>
        /// <param name="DiscountID">Discount identifier</param>
        /// <param name="DiscountTypeID">The discount type identifier</param>
        /// <param name="DiscountRequirementID">The discount requirement identifier</param>
        /// <param name="Name">The name</param>
        /// <param name="UsePercentage">A value indicating whether to use percentage</param>
        /// <param name="DiscountPercentage">The discount percentage</param>
        /// <param name="DiscountAmount">The discount amount</param>
        /// <param name="StartDate">The discount start date and time</param>
        /// <param name="EndDate">The discount end date and time</param>
        /// <param name="RequiresCouponCode">The value indicating whether discount requires coupon code</param>
        /// <param name="CouponCode">The coupon code</param>
        /// <param name="Deleted">A value indicating whether the entity has been deleted</param>
        /// <returns>Discount</returns>
        public override DBDiscount UpdateDiscount(int DiscountID, int DiscountTypeID, int DiscountRequirementID, string Name, bool UsePercentage, decimal DiscountPercentage, decimal DiscountAmount,
                                                  DateTime StartDate, DateTime EndDate, bool RequiresCouponCode, string CouponCode, bool Deleted)
        {
            DBDiscount discount  = null;
            Database   db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand  dbCommand = db.GetStoredProcCommand("Nop_DiscountUpdate");

            db.AddInParameter(dbCommand, "DiscountID", DbType.Int32, DiscountID);
            db.AddInParameter(dbCommand, "DiscountTypeID", DbType.Int32, DiscountTypeID);
            db.AddInParameter(dbCommand, "DiscountRequirementID", DbType.Int32, DiscountRequirementID);
            db.AddInParameter(dbCommand, "Name", DbType.String, Name);
            db.AddInParameter(dbCommand, "UsePercentage", DbType.Boolean, UsePercentage);
            db.AddInParameter(dbCommand, "DiscountPercentage", DbType.Decimal, DiscountPercentage);
            db.AddInParameter(dbCommand, "DiscountAmount", DbType.Decimal, DiscountAmount);
            db.AddInParameter(dbCommand, "StartDate", DbType.DateTime, StartDate);
            db.AddInParameter(dbCommand, "EndDate", DbType.DateTime, EndDate);
            db.AddInParameter(dbCommand, "RequiresCouponCode", DbType.Boolean, RequiresCouponCode);
            db.AddInParameter(dbCommand, "CouponCode", DbType.String, CouponCode);
            db.AddInParameter(dbCommand, "Deleted", DbType.Boolean, Deleted);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                discount = GetDiscountByID(DiscountID);
            }

            return(discount);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates the discount
        /// </summary>
        /// <param name="discountId">Discount identifier</param>
        /// <param name="discountTypeId">The discount type identifier</param>
        /// <param name="discountRequirementId">The discount requirement identifier</param>
        /// <param name="discountLimitationId">The discount limitation identifier</param>
        /// <param name="name">The name</param>
        /// <param name="usePercentage">A value indicating whether to use percentage</param>
        /// <param name="discountPercentage">The discount percentage</param>
        /// <param name="discountAmount">The discount amount</param>
        /// <param name="startDate">The discount start date and time</param>
        /// <param name="endDate">The discount end date and time</param>
        /// <param name="requiresCouponCode">The value indicating whether discount requires coupon code</param>
        /// <param name="couponCode">The coupon code</param>
        /// <param name="deleted">A value indicating whether the entity has been deleted</param>
        /// <returns>Discount</returns>
        public override DBDiscount UpdateDiscount(int discountId, int discountTypeId,
                                                  int discountRequirementId, int discountLimitationId,
                                                  string name, bool usePercentage, decimal discountPercentage,
                                                  decimal discountAmount, DateTime startDate, DateTime endDate,
                                                  bool requiresCouponCode, string couponCode, bool deleted)
        {
            DBDiscount item      = null;
            Database   db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand  dbCommand = db.GetStoredProcCommand("Nop_DiscountUpdate");

            db.AddInParameter(dbCommand, "DiscountID", DbType.Int32, discountId);
            db.AddInParameter(dbCommand, "DiscountTypeID", DbType.Int32, discountTypeId);
            db.AddInParameter(dbCommand, "DiscountRequirementID", DbType.Int32, discountRequirementId);
            db.AddInParameter(dbCommand, "DiscountLimitationID", DbType.Int32, discountLimitationId);
            db.AddInParameter(dbCommand, "Name", DbType.String, name);
            db.AddInParameter(dbCommand, "UsePercentage", DbType.Boolean, usePercentage);
            db.AddInParameter(dbCommand, "DiscountPercentage", DbType.Decimal, discountPercentage);
            db.AddInParameter(dbCommand, "DiscountAmount", DbType.Decimal, discountAmount);
            db.AddInParameter(dbCommand, "StartDate", DbType.DateTime, startDate);
            db.AddInParameter(dbCommand, "EndDate", DbType.DateTime, endDate);
            db.AddInParameter(dbCommand, "RequiresCouponCode", DbType.Boolean, requiresCouponCode);
            db.AddInParameter(dbCommand, "CouponCode", DbType.String, couponCode);
            db.AddInParameter(dbCommand, "Deleted", DbType.Boolean, deleted);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                item = GetDiscountById(discountId);
            }

            return(item);
        }
        /// <summary>
        /// Gets all discounts
        /// </summary>
        /// <param name="showHidden">A value indicating whether to show hidden records</param>
        /// <param name="DiscountTypeID">Discount type identifier; null to load all discount</param>
        /// <returns>Discount collection</returns>
        public override DBDiscountCollection GetAllDiscounts(bool showHidden, int?DiscountTypeID)
        {
            DBDiscountCollection discountCollection = new DBDiscountCollection();
            Database             db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand            dbCommand = db.GetStoredProcCommand("Nop_DiscountLoadAll");

            db.AddInParameter(dbCommand, "ShowHidden", DbType.Boolean, showHidden);
            if (DiscountTypeID.HasValue)
            {
                db.AddInParameter(dbCommand, "DiscountTypeID", DbType.Int32, DiscountTypeID.Value);
            }
            else
            {
                db.AddInParameter(dbCommand, "DiscountTypeID", DbType.Int32, null);
            }
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBDiscount discount = GetDiscountFromReader(dataReader);
                    discountCollection.Add(discount);
                }
            }

            return(discountCollection);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets a discount
        /// </summary>
        /// <param name="discountId">Discount identifier</param>
        /// <returns>Discount</returns>
        public override DBDiscount GetDiscountById(int discountId)
        {
            DBDiscount item      = null;
            Database   db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand  dbCommand = db.GetStoredProcCommand("Nop_DiscountLoadByPrimaryKey");

            db.AddInParameter(dbCommand, "DiscountID", DbType.Int32, discountId);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    item = GetDiscountFromReader(dataReader);
                }
            }
            return(item);
        }
 private DBDiscount GetDiscountFromReader(IDataReader dataReader)
 {
     DBDiscount discount = new DBDiscount();
     discount.DiscountID = NopSqlDataHelper.GetInt(dataReader, "DiscountID");
     discount.DiscountTypeID = NopSqlDataHelper.GetInt(dataReader, "DiscountTypeID");
     discount.DiscountRequirementID = NopSqlDataHelper.GetInt(dataReader, "DiscountRequirementID");
     discount.Name = NopSqlDataHelper.GetString(dataReader, "Name");
     discount.UsePercentage = NopSqlDataHelper.GetBoolean(dataReader, "UsePercentage");
     discount.DiscountPercentage = NopSqlDataHelper.GetDecimal(dataReader, "DiscountPercentage");
     discount.DiscountAmount = NopSqlDataHelper.GetDecimal(dataReader, "DiscountAmount");
     discount.StartDate = NopSqlDataHelper.GetUtcDateTime(dataReader, "StartDate");
     discount.EndDate = NopSqlDataHelper.GetUtcDateTime(dataReader, "EndDate");
     discount.RequiresCouponCode = NopSqlDataHelper.GetBoolean(dataReader, "RequiresCouponCode");
     discount.CouponCode = NopSqlDataHelper.GetString(dataReader, "CouponCode");
     discount.Deleted = NopSqlDataHelper.GetBoolean(dataReader, "Deleted");
     return discount;
 }
        private DBDiscount GetDiscountFromReader(IDataReader dataReader)
        {
            DBDiscount discount = new DBDiscount();

            discount.DiscountID            = NopSqlDataHelper.GetInt(dataReader, "DiscountID");
            discount.DiscountTypeID        = NopSqlDataHelper.GetInt(dataReader, "DiscountTypeID");
            discount.DiscountRequirementID = NopSqlDataHelper.GetInt(dataReader, "DiscountRequirementID");
            discount.Name               = NopSqlDataHelper.GetString(dataReader, "Name");
            discount.UsePercentage      = NopSqlDataHelper.GetBoolean(dataReader, "UsePercentage");
            discount.DiscountPercentage = NopSqlDataHelper.GetDecimal(dataReader, "DiscountPercentage");
            discount.DiscountAmount     = NopSqlDataHelper.GetDecimal(dataReader, "DiscountAmount");
            discount.StartDate          = NopSqlDataHelper.GetUtcDateTime(dataReader, "StartDate");
            discount.EndDate            = NopSqlDataHelper.GetUtcDateTime(dataReader, "EndDate");
            discount.RequiresCouponCode = NopSqlDataHelper.GetBoolean(dataReader, "RequiresCouponCode");
            discount.CouponCode         = NopSqlDataHelper.GetString(dataReader, "CouponCode");
            discount.Deleted            = NopSqlDataHelper.GetBoolean(dataReader, "Deleted");
            return(discount);
        }
Ejemplo n.º 7
0
        private DBDiscount GetDiscountFromReader(IDataReader dataReader)
        {
            var item = new DBDiscount();

            item.DiscountId            = NopSqlDataHelper.GetInt(dataReader, "DiscountID");
            item.DiscountTypeId        = NopSqlDataHelper.GetInt(dataReader, "DiscountTypeID");
            item.DiscountLimitationId  = NopSqlDataHelper.GetInt(dataReader, "DiscountLimitationID");
            item.DiscountRequirementId = NopSqlDataHelper.GetInt(dataReader, "DiscountRequirementID");
            item.Name               = NopSqlDataHelper.GetString(dataReader, "Name");
            item.UsePercentage      = NopSqlDataHelper.GetBoolean(dataReader, "UsePercentage");
            item.DiscountPercentage = NopSqlDataHelper.GetDecimal(dataReader, "DiscountPercentage");
            item.DiscountAmount     = NopSqlDataHelper.GetDecimal(dataReader, "DiscountAmount");
            item.StartDate          = NopSqlDataHelper.GetUtcDateTime(dataReader, "StartDate");
            item.EndDate            = NopSqlDataHelper.GetUtcDateTime(dataReader, "EndDate");
            item.RequiresCouponCode = NopSqlDataHelper.GetBoolean(dataReader, "RequiresCouponCode");
            item.CouponCode         = NopSqlDataHelper.GetString(dataReader, "CouponCode");
            item.Deleted            = NopSqlDataHelper.GetBoolean(dataReader, "Deleted");
            return(item);
        }
        /// <summary>
        /// Gets a discount collection of a category
        /// </summary>
        /// <param name="CategoryID">Category identifier</param>
        /// <param name="showHidden">A value indicating whether to show hidden records</param>
        /// <returns>Discount collection</returns>
        public override DBDiscountCollection GetDiscountsByCategoryID(int CategoryID, bool showHidden)
        {
            DBDiscountCollection discountCollection = new DBDiscountCollection();
            Database             db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand            dbCommand = db.GetStoredProcCommand("Nop_DiscountLoadByCategoryID");

            db.AddInParameter(dbCommand, "ShowHidden", DbType.Boolean, showHidden);
            db.AddInParameter(dbCommand, "CategoryID", DbType.Int32, CategoryID);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBDiscount discount = GetDiscountFromReader(dataReader);
                    discountCollection.Add(discount);
                }
            }

            return(discountCollection);
        }
Ejemplo n.º 9
0
        private static Discount DBMapping(DBDiscount dbItem)
        {
            if (dbItem == null)
                return null;

            Discount item = new Discount();
            item.DiscountID = dbItem.DiscountID;
            item.DiscountTypeID = dbItem.DiscountTypeID;
            item.DiscountRequirementID = dbItem.DiscountRequirementID;
            item.Name = dbItem.Name;
            item.UsePercentage = dbItem.UsePercentage;
            item.DiscountPercentage = dbItem.DiscountPercentage;
            item.DiscountAmount = dbItem.DiscountAmount;
            item.StartDate = dbItem.StartDate;
            item.EndDate = dbItem.EndDate;
            item.RequiresCouponCode = dbItem.RequiresCouponCode;
            item.CouponCode = dbItem.CouponCode;
            item.Deleted = dbItem.Deleted;

            return item;
        }