private DBShippingMethod GetShippingMethodFromReader(IDataReader dataReader) { DBShippingMethod shippingMethod = new DBShippingMethod(); shippingMethod.ShippingMethodID = NopSqlDataHelper.GetInt(dataReader, "ShippingMethodID"); shippingMethod.Name = NopSqlDataHelper.GetString(dataReader, "Name"); shippingMethod.Description = NopSqlDataHelper.GetString(dataReader, "Description"); shippingMethod.DisplayOrder = NopSqlDataHelper.GetInt(dataReader, "DisplayOrder"); return(shippingMethod); }
private DBShippingMethod GetShippingMethodFromReader(IDataReader dataReader) { var item = new DBShippingMethod(); item.ShippingMethodId = NopSqlDataHelper.GetInt(dataReader, "ShippingMethodID"); item.Name = NopSqlDataHelper.GetString(dataReader, "Name"); item.Description = NopSqlDataHelper.GetString(dataReader, "Description"); item.DisplayOrder = NopSqlDataHelper.GetInt(dataReader, "DisplayOrder"); return(item); }
/// <summary> /// Gets all shipping methods /// </summary> /// <returns>Shipping method collection</returns> public override DBShippingMethodCollection GetAllShippingMethods() { DBShippingMethodCollection shippingMethodCollection = new DBShippingMethodCollection(); Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_ShippingMethodLoadAll"); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { DBShippingMethod shippingMethod = GetShippingMethodFromReader(dataReader); shippingMethodCollection.Add(shippingMethod); } } return(shippingMethodCollection); }
/// <summary> /// Inserts a shipping method /// </summary> /// <param name="Name">The name</param> /// <param name="Description">The description</param> /// <param name="DisplayOrder">The display order</param> /// <returns>Shipping method</returns> public override DBShippingMethod InsertShippingMethod(string Name, string Description, int DisplayOrder) { DBShippingMethod shippingMethod = null; Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_ShippingMethodInsert"); db.AddOutParameter(dbCommand, "ShippingMethodID", DbType.Int32, 0); db.AddInParameter(dbCommand, "Name", DbType.String, Name); db.AddInParameter(dbCommand, "Description", DbType.String, Description); db.AddInParameter(dbCommand, "DisplayOrder", DbType.Int32, DisplayOrder); if (db.ExecuteNonQuery(dbCommand) > 0) { int ShippingMethodID = Convert.ToInt32(db.GetParameterValue(dbCommand, "@ShippingMethodID")); shippingMethod = GetShippingMethodByID(ShippingMethodID); } return(shippingMethod); }
/// <summary> /// Updates the shipping method /// </summary> /// <param name="shippingMethodId">The shipping method identifier</param> /// <param name="name">The name</param> /// <param name="description">The description</param> /// <param name="displayOrder">The display order</param> /// <returns>Shipping method</returns> public override DBShippingMethod UpdateShippingMethod(int shippingMethodId, string name, string description, int displayOrder) { DBShippingMethod item = null; Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_ShippingMethodUpdate"); db.AddInParameter(dbCommand, "ShippingMethodID", DbType.Int32, shippingMethodId); db.AddInParameter(dbCommand, "Name", DbType.String, name); db.AddInParameter(dbCommand, "Description", DbType.String, description); db.AddInParameter(dbCommand, "DisplayOrder", DbType.Int32, displayOrder); if (db.ExecuteNonQuery(dbCommand) > 0) { item = GetShippingMethodById(shippingMethodId); } return(item); }
/// <summary> /// Gets a shipping method /// </summary> /// <param name="ShippingMethodID">The shipping method identifier</param> /// <returns>Shipping method</returns> public override DBShippingMethod GetShippingMethodByID(int ShippingMethodID) { DBShippingMethod shippingMethod = null; if (ShippingMethodID == 0) { return(shippingMethod); } Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_ShippingMethodLoadByPrimaryKey"); db.AddInParameter(dbCommand, "ShippingMethodID", DbType.Int32, ShippingMethodID); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { shippingMethod = GetShippingMethodFromReader(dataReader); } } return(shippingMethod); }