Interface IModelExtensionCommandHandler<TModel, TExtensionModel>
- Namespace
- Dynamicweb.CoreUI.Data
- Assembly
- Dynamicweb.CoreUI.dll
Handles the persistence of a model extension's fields whenever a command carrying TModel
is executed.
public interface IModelExtensionCommandHandler<TModel, TExtensionModel> where TModel : DataViewModelBase, new() where TExtensionModel : class, new()
Type Parameters
TModelThe model this extension applies to.
TExtensionModelThe extension's own data, added to
TModel's edit screen by a matching EditScreenModelExtensionInjector<TScreen, TModel, TExtensionModel>.
Remarks
Registered against TModel, not any one command - unlike ICommandHandler<TCommand, TModel>,
which is strictly one handler per command, several independent extensions can each persist their own fields from a
single save, and a single extension applies no matter which command posted to TModel is
handling the save. A handler only runs when its extension's fields were actually present in the posted request; an
extension that does not apply to a given record (because its injector did not render any editors for it) never
triggers a handler call.
Methods
Handle(CommandBase<TModel>, TModel, TExtensionModel)
Persists extension for model after command has
successfully handled the core model.
void Handle(CommandBase<TModel> command, TModel model, TExtensionModel extension)
Parameters
commandCommandBase<TModel>The command that was executed. Not constrained to any one command type, since the extension applies to
TModelregardless of which command carried it.modelTModelThe saved model.
extensionTExtensionModelThe extension's posted, merged data.
Load(TModel)
Loads the extension's current persisted value for model, used both to render the edit
screen and as the "original" side of the command log diff.
TExtensionModel Load(TModel model)
Parameters
modelTModelThe model being edited or saved.
Returns
- TExtensionModel