Class ShadowEditService
- Namespace
- Dynamicweb.CoreUI.Data.ShadowEditing
- Assembly
- Dynamicweb.CoreUI.dll
Creates, loads and persists the ShadowEdit instances that hold a user's pending, not yet committed modifications to a data model.
public sealed class ShadowEditService
- Inheritance
-
ShadowEditService
- Inherited Members
Constructors
ShadowEditService(ShadowEditRepositoryBase)
Creates, loads and persists the ShadowEdit instances that hold a user's pending, not yet committed modifications to a data model.
public ShadowEditService(ShadowEditRepositoryBase repository)
Parameters
repositoryShadowEditRepositoryBase
Methods
DeleteShadowEdit(string)
Deletes the shadow edit with the given id, permanently discarding its pending modifications.
public void DeleteShadowEdit(string id)
Parameters
idstringThe shadow edit id. Unknown ids are ignored.
GetShadowEdit(string)
Gets the shadow edit with the given id.
public ShadowEdit? GetShadowEdit(string id)
Parameters
idstringThe shadow edit id.
Returns
- ShadowEdit
The matching ShadowEdit, or null if none exists.
GetShadowEdit<T>(string)
Gets the shadow edit with the given id, typed to its data model.
public ShadowEdit<T>? GetShadowEdit<T>(string id)
Parameters
idstringThe shadow edit id.
Returns
- ShadowEdit<T>
The matching shadow edit, or null if no shadow edit has that id or it edits another model type.
Type Parameters
TThe data model type the shadow edit is expected to edit.
GetShadowEdit<T>(T?, DataQueryModelBase<T>?)
Starts editing a model by creating a shadow edit for it, assigning it a new id and persisting it.
public ShadowEdit<T> GetShadowEdit<T>(T? model, DataQueryModelBase<T>? query)
Parameters
modelTThe model to edit, or null to resolve it from the query (or a new instance of
Twhen there is no query).queryDataQueryModelBase<T>The query the model originates from, or null when the model is not query bound.
Returns
- ShadowEdit<T>
The newly created shadow edit, with no modifications applied yet.
Type Parameters
TThe data model type being edited.
Remarks
This always creates a new shadow edit; use GetShadowEdit<T>(string) to load an existing one.
GetShadowEdit<T>(T?, DataQueryModelBase<T>?, string?)
Starts editing a model by creating a shadow edit for it, assigning it a new id and persisting it.
public ShadowEdit<T> GetShadowEdit<T>(T? model, DataQueryModelBase<T>? query, string? id)
Parameters
modelTThe model to edit, or null to resolve it from the query (or a new instance of
Twhen there is no query).queryDataQueryModelBase<T>The query the model originates from, or null when the model is not query bound.
idstringThe shadow edit id to assign. If null, a new id is generated.
Returns
- ShadowEdit<T>
The newly created shadow edit, with no modifications applied yet.
Type Parameters
TThe data model type being edited.
Remarks
This always creates a new shadow edit; use GetShadowEdit<T>(string) to load an existing one.
GetShadowEdits(Type)
Gets every shadow edit for the given data model type.
public IEnumerable<ShadowEdit> GetShadowEdits(Type modelType)
Parameters
modelTypeTypeThe data model type the shadow edits belong to.
Returns
- IEnumerable<ShadowEdit>
The matching shadow edits, or an empty sequence if there are none.
GetShadowEdits<T>()
Gets every shadow edit for the given data model type.
public IEnumerable<ShadowEdit<T>> GetShadowEdits<T>()
Returns
- IEnumerable<ShadowEdit<T>>
The matching shadow edits, or an empty sequence if there are none.
Type Parameters
TThe data model type the shadow edits belong to.
HasKey(string)
Determines whether a shadow edit with the given id exists.
public bool HasKey(string key)
Parameters
keystringThe shadow edit id to look for.
Returns
ResetShadowEdit(string)
Resets the shadow edit with the given id, discarding its modifications and rebuilding its baseline from the current model, and persists it.
public bool ResetShadowEdit(string id)
Parameters
idstringThe shadow edit id.
Returns
Remarks
Call this after a save so that the shadow edit is kept alive, but compares subsequent edits against the newly committed values instead of the stale ones.
SaveShadowEdit(ShadowEdit)
Persists the shadow edit and its modifications, so it can be loaded again by its id.
public void SaveShadowEdit(ShadowEdit shadowEdit)
Parameters
shadowEditShadowEditThe shadow edit to persist.
SaveShadowEdit<T>(ShadowEdit<T>)
Persists the shadow edit and its modifications, so it can be loaded again by its id.
public void SaveShadowEdit<T>(ShadowEdit<T> shadowEdit)
Parameters
shadowEditShadowEdit<T>The shadow edit to persist.
Type Parameters
TThe data model type being edited.