Guides
Guides

Event Model

In general, Merchello follows Umbraco's service event model in that most services expose:

NameDescription
CreatingOccurs before create
CreatedOccurs after create
SavingOccurs before saving
SavedOccurs after saved
DeletingOccurs before deleting
DeletedOccurs after delete

Example Service Event Usage

/// <summary>
/// The umbraco event handler.
/// </summary>
public class UmbracoEventHandler : ApplicationEventHandler
{

  /// <summary>
  /// Handles Umbraco Events.
  /// </summary>
  /// <param name="umbracoApplication">
  /// The <see cref="UmbracoApplicationBase"/>.
  /// </param>
  /// <param name="applicationContext">
  /// Umbraco <see cref="ApplicationContext"/>.
  /// </param>
  protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
  {
      StoreSettingService.Saved += StoreSettingServiceOnSaved;
  }
  
  /// <summary>
  /// Clears the Bazaar currency if Merchello store settings are saved.
  /// </summary>
  /// <param name="sender">
  /// The sender.
  /// </param>
  /// <param name="e">
  /// The save event args.
  /// </param>
  private static void StoreSettingServiceOnSaved(IStoreSettingService sender, SaveEventArgs<IStoreSetting> e)
  {
    // do something when a setting is saved
  }
}