private DBDiscountUsageHistory GetDiscountUsageHistoryFromReader(IDataReader dataReader) { var item = new DBDiscountUsageHistory(); item.DiscountUsageHistoryId = NopSqlDataHelper.GetInt(dataReader, "DiscountUsageHistoryID"); item.DiscountId = NopSqlDataHelper.GetInt(dataReader, "DiscountID"); item.CustomerId = NopSqlDataHelper.GetInt(dataReader, "CustomerID"); item.OrderId = NopSqlDataHelper.GetInt(dataReader, "OrderID"); item.CreatedOn = NopSqlDataHelper.GetUtcDateTime(dataReader, "CreatedOn"); return(item); }
/// <summary> /// Gets a discount usage history entry /// </summary> /// <param name="discountUsageHistoryId">Discount usage history entry identifier</param> /// <returns>Discount usage history entry</returns> public override DBDiscountUsageHistory GetDiscountUsageHistoryById(int discountUsageHistoryId) { DBDiscountUsageHistory item = null; Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_DiscountUsageHistoryLoadByPrimaryKey"); db.AddInParameter(dbCommand, "DiscountUsageHistoryID", DbType.Int32, discountUsageHistoryId); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { item = GetDiscountUsageHistoryFromReader(dataReader); } } return(item); }
/// <summary> /// Updates the discount usage history entry /// </summary> /// <param name="discountUsageHistoryId">discount usage history entry identifier</param> /// <param name="discountId">Discount type identifier</param> /// <param name="customerId">Customer identifier</param> /// <param name="orderId">Order identifier</param> /// <param name="createdOn">A date and time of instance creation</param> /// <returns>Discount usage history entry</returns> public override DBDiscountUsageHistory UpdateDiscountUsageHistory(int discountUsageHistoryId, int discountId, int customerId, int orderId, DateTime createdOn) { DBDiscountUsageHistory item = null; Database db = NopSqlDataHelper.CreateConnection(_sqlConnectionString); DbCommand dbCommand = db.GetStoredProcCommand("Nop_DiscountUsageHistoryUpdate"); db.AddInParameter(dbCommand, "DiscountUsageHistoryID", DbType.Int32, discountUsageHistoryId); db.AddInParameter(dbCommand, "DiscountID", DbType.Int32, discountId); db.AddInParameter(dbCommand, "CustomerID", DbType.Int32, customerId); db.AddInParameter(dbCommand, "OrderID", DbType.Int32, orderId); db.AddInParameter(dbCommand, "CreatedOn", DbType.DateTime, createdOn); if (db.ExecuteNonQuery(dbCommand) > 0) { item = GetDiscountUsageHistoryById(discountUsageHistoryId); } return(item); }