/// <summary>
        /// Updates the currency
        /// </summary>
        /// <param name="currencyId">Currency identifier</param>
        /// <param name="name">The name</param>
        /// <param name="currencyCode">The currency code</param>
        /// <param name="rate">The rate</param>
        /// <param name="displayLocale">The display locale</param>
        /// <param name="customFormatting">The custom formatting</param>
        /// <param name="published">A value indicating whether the entity is published</param>
        /// <param name="displayOrder">The display order</param>
        /// <param name="createdOn">The date and time of instance creation</param>
        /// <param name="updatedOn">The date and time of instance update</param>
        /// <returns>A currency</returns>
        public override DBCurrency UpdateCurrency(int currencyId, string name,
                                                  string currencyCode, decimal rate, string displayLocale,
                                                  string customFormatting, bool published, int displayOrder,
                                                  DateTime createdOn, DateTime updatedOn)
        {
            DBCurrency item      = null;
            Database   db        = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand  dbCommand = db.GetStoredProcCommand("Nop_CurrencyUpdate");

            db.AddInParameter(dbCommand, "CurrencyID", DbType.Int32, currencyId);
            db.AddInParameter(dbCommand, "Name", DbType.String, name);
            db.AddInParameter(dbCommand, "CurrencyCode", DbType.String, currencyCode);
            db.AddInParameter(dbCommand, "Rate", DbType.Decimal, rate);
            db.AddInParameter(dbCommand, "DisplayLocale", DbType.String, displayLocale);
            db.AddInParameter(dbCommand, "CustomFormatting", DbType.String, customFormatting);
            db.AddInParameter(dbCommand, "Published", DbType.Boolean, published);
            db.AddInParameter(dbCommand, "DisplayOrder", DbType.Int32, displayOrder);
            db.AddInParameter(dbCommand, "CreatedOn", DbType.DateTime, createdOn);
            db.AddInParameter(dbCommand, "UpdatedOn", DbType.DateTime, updatedOn);
            if (db.ExecuteNonQuery(dbCommand) > 0)
            {
                item = GetCurrencyById(currencyId);
            }

            return(item);
        }
 private DBCurrency GetCurrencyFromReader(IDataReader dataReader)
 {
     DBCurrency currency = new DBCurrency();
     currency.CurrencyID = NopSqlDataHelper.GetInt(dataReader, "CurrencyID");
     currency.Name = NopSqlDataHelper.GetString(dataReader, "Name");
     currency.CurrencyCode = NopSqlDataHelper.GetString(dataReader, "CurrencyCode");
     currency.Rate = NopSqlDataHelper.GetDecimal(dataReader, "Rate");
     currency.DisplayLocale = NopSqlDataHelper.GetString(dataReader, "DisplayLocale");
     currency.CustomFormatting = NopSqlDataHelper.GetString(dataReader, "CustomFormatting");
     currency.Published = NopSqlDataHelper.GetBoolean(dataReader, "Published");
     currency.DisplayOrder = NopSqlDataHelper.GetInt(dataReader, "DisplayOrder");
     currency.CreatedOn = NopSqlDataHelper.GetUtcDateTime(dataReader, "CreatedOn");
     currency.UpdatedOn = NopSqlDataHelper.GetUtcDateTime(dataReader, "UpdatedOn");
     return currency;
 }
        /// <summary>
        /// Gets all currencies
        /// </summary>
        /// <returns>Currency collection</returns>
        public override DBCurrencyCollection GetAllCurrencies(bool showHidden)
        {
            DBCurrencyCollection currencyCollection = new DBCurrencyCollection();
            Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_CurrencyLoadAll");
            db.AddInParameter(dbCommand, "ShowHidden", DbType.Boolean, showHidden);
            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    DBCurrency currency = GetCurrencyFromReader(dataReader);
                    currencyCollection.Add(currency);
                }
            }

            return currencyCollection;
        }
 /// <summary>
 /// Gets a currency
 /// </summary>
 /// <param name="CurrencyID">Currency identifier</param>
 /// <returns>Currency</returns>
 public override DBCurrency GetCurrencyByID(int CurrencyID)
 {
     DBCurrency currency = null;
     if (CurrencyID == 0)
         return currency;
     Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
     DbCommand dbCommand = db.GetStoredProcCommand("Nop_CurrencyLoadByPrimaryKey");
     db.AddInParameter(dbCommand, "CurrencyID", DbType.Int32, CurrencyID);
     using (IDataReader dataReader = db.ExecuteReader(dbCommand))
     {
         if (dataReader.Read())
         {
             currency = GetCurrencyFromReader(dataReader);
         }
     }
     return currency;
 }
예제 #5
0
        private static Currency DBMapping(DBCurrency dbItem)
        {
            if (dbItem == null)
                return null;

            Currency item = new Currency();
            item.CurrencyID = dbItem.CurrencyID;
            item.Name = dbItem.Name;
            item.CurrencyCode = dbItem.CurrencyCode;
            item.Rate = dbItem.Rate;
            item.DisplayLocale = dbItem.DisplayLocale;
            item.CustomFormatting = dbItem.CustomFormatting;
            item.Published = dbItem.Published;
            item.DisplayOrder = dbItem.DisplayOrder;
            item.CreatedOn = dbItem.CreatedOn;
            item.UpdatedOn = dbItem.UpdatedOn;

            return item;
        }
        /// <summary>
        /// Updates the currency
        /// </summary>
        /// <param name="CurrencyID">Currency identifier</param>
        /// <param name="Name">The name</param>
        /// <param name="CurrencyCode">The currency code</param>
        /// <param name="Rate">The rate</param>
        /// <param name="DisplayLocale">The display locale</param>
        /// <param name="CustomFormatting">The custom formatting</param>
        /// <param name="Published">A value indicating whether the entity is published</param>
        /// <param name="DisplayOrder">The display order</param>
        /// <param name="CreatedOn">The date and time of instance creation</param>
        /// <param name="UpdatedOn">The date and time of instance update</param>
        /// <returns>A currency</returns>
        public override DBCurrency UpdateCurrency(int CurrencyID, string Name, string CurrencyCode, decimal Rate,
           string DisplayLocale, string CustomFormatting, bool Published, int DisplayOrder, DateTime CreatedOn, DateTime UpdatedOn)
        {
            DBCurrency currency = null;
            Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString);
            DbCommand dbCommand = db.GetStoredProcCommand("Nop_CurrencyUpdate");
            db.AddInParameter(dbCommand, "CurrencyID", DbType.Int32, CurrencyID);
            db.AddInParameter(dbCommand, "Name", DbType.String, Name);
            db.AddInParameter(dbCommand, "CurrencyCode", DbType.String, CurrencyCode);
            db.AddInParameter(dbCommand, "Rate", DbType.Decimal, Rate);
            db.AddInParameter(dbCommand, "DisplayLocale", DbType.String, DisplayLocale);
            db.AddInParameter(dbCommand, "CustomFormatting", DbType.String, CustomFormatting);
            db.AddInParameter(dbCommand, "Published", DbType.Boolean, Published);
            db.AddInParameter(dbCommand, "DisplayOrder", DbType.Int32, DisplayOrder);
            db.AddInParameter(dbCommand, "CreatedOn", DbType.DateTime, CreatedOn);
            db.AddInParameter(dbCommand, "UpdatedOn", DbType.DateTime, UpdatedOn);
            if (db.ExecuteNonQuery(dbCommand) > 0)
                currency = GetCurrencyByID(CurrencyID);

            return currency;
        }