Share via


How to Use the DiscountPrioritySet

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

The following example programmatically accesses the DiscountPrioritySet.

To access the DiscountPrioritySet

  1. Create a MarketingServiceAgent object. This type is visible when you add a Web reference to your project.

  2. Create a MarketingContext object.

  3. Create a DiscountPrioritySet object.

  4. Use the DiscountPriorities property of this object to access and alter the discount priorities.

  5. Use the UpdateDiscountPriorities method to save the changes.

Example

MarketingServiceAgent agent = new MarketingServiceAgent(url);
MarketingSystem marketingSystem = new MarketingSystem(agent);

// Swap the priority of the Discounts with ID=23 and ID=24.
Discount di1 = (Discount)marketingSystem.CampaignItems.GetCampaignItem(23);
Discount di2 = (Discount)marketingSystem.CampaignItems.GetCampaignItem(24);

DiscountPrioritySet ds = new DiscountPrioritySet();
ds.DiscountPriorities.AddDiscountPriority(di1.Id, di2.Priority);
ds.DiscountPriorities.AddDiscountPriority(di2.Id, di1.Priority);

marketingSystem.CampaignItems.UpdateDiscountPriorities(ds);

See Also

Other Resources

DiscountPrioritySet