Class Item
Represents an item in the structure.
Inherited Members
Namespace: DataWeb.Structure
Assembly: DataWeb.Core.dll
Syntax
public sealed class Item
Remarks
Initializes a new instance of the Item class.
Constructors
Item(IStructureService, IItemStore, IRelationStore)
Represents an item in the structure.
Declaration
public Item(IStructureService structureService, IItemStore itemStore, IRelationStore relationStore)
Parameters
Type | Name | Description |
---|---|---|
IStructureService | structureService | The structure service. |
IItemStore | itemStore | The item store. |
IRelationStore | relationStore | The relation store. |
Remarks
Initializes a new instance of the Item class.
Properties
DateCreated
Gets or sets the date the item was created.
Declaration
public DateTimeOffset? DateCreated { get; set; }
Property Value
Type | Description |
---|---|
DateTimeOffset? |
DateModified
Gets or sets the date the item was last modified.
Declaration
public DateTimeOffset? DateModified { get; set; }
Property Value
Type | Description |
---|---|
DateTimeOffset? |
IdMaster
Gets or sets the unique identifier.
Declaration
public string IdMaster { get; set; }
Property Value
Type | Description |
---|---|
string |
IsCompleted
Gets or sets whether the item is completed.
Declaration
public bool IsCompleted { get; set; }
Property Value
Type | Description |
---|---|
bool |
Label
Gets or sets the label of the item.
Declaration
public string Label { get; set; }
Property Value
Type | Description |
---|---|
string |
Status
Gets or sets the status of the item.
Declaration
public ItemStatus Status { get; set; }
Property Value
Type | Description |
---|---|
ItemStatus |
Methods
CheckSectionDataChanges(Dictionary<string, object>, Dictionary<string, object>)
Checks provided section data against original section data in order to get modified fields.
Declaration
public static List<string> CheckSectionDataChanges(Dictionary<string, object> sectionData, Dictionary<string, object> providedSectionData)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<string, object> | sectionData | The original section data. |
Dictionary<string, object> | providedSectionData | The provided section data. |
Returns
Type | Description |
---|---|
List<string> |
DeleteAsync(CancellationToken)
Deletes this item by changing the status to Deleted.
Declaration
public Task DeleteAsync(CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
Init(MasterPart)
Initializes the item with the specified master part.
Declaration
public void Init(Item.MasterPart masterPart)
Parameters
Type | Name | Description |
---|---|---|
Item.MasterPart | masterPart | The Item.MasterPart to initialize the item. |
InitAsync(string, CancellationToken)
Initializes the item with the specified Id.
Declaration
public Task InitAsync(string idMaster, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | idMaster | The Id of the item. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
LoadSectionAsync(string, string, string, CancellationToken)
Loads a Item.SectionPart instance from the data store for a given section name, version culture and version name.
If the sectionDataName
is undefined, or the section is not found, an exception will be thrown.
If the versionCulture
or versionName
are not provided, new defaults will be used.
Declaration
public Task<Item.SectionPart> LoadSectionAsync(string sectionDataName, string versionCulture = null, string versionName = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | sectionDataName | The name of the section data. |
string | versionCulture | The version culture. |
string | versionName | The version name. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<Item.SectionPart> | A Item.SectionPart instance. |
RemoveRelationAsync(string, string, CancellationToken)
Removes a relation between the current item and another item.
Declaration
public Task RemoveRelationAsync(string parentIdMaster, string sectionName, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | parentIdMaster | The Id of the parent item. |
string | sectionName | The name of the section that defines the relationship. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
SaveAsActiveAsync(string, string, string, string, Dictionary<string, object>, CancellationToken)
Saves the item's master part, section part, and relation part as active.
Declaration
public Task<List<string>> SaveAsActiveAsync(string label, string parentIdMaster, string sectionName, string sectionDataName, Dictionary<string, object> sectionData, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | label | The label of the item. |
string | parentIdMaster | The id of the parent item. |
string | sectionName | The name of the section. |
string | sectionDataName | The name of the section data. |
Dictionary<string, object> | sectionData | The section data dictionary. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<List<string>> | A list of modified fields. |
SaveMasterAsActiveAsync(string, CancellationToken)
Saves the current item as active, with the provided label.
Declaration
public Task SaveMasterAsActiveAsync(string label = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | label | The label to set on the item. If null, the current label will be used. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task | A task representing the asynchronous operation. |
SaveMasterAsync(CancellationToken)
Saves the current item to the item store.
Declaration
public Task SaveMasterAsync(CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task | A task representing the asynchronous operation. |
Exceptions
Type | Condition |
---|---|
Exception | Thrown when IdMaster is not defined or not valid. |
SaveRelationAsync(string, string, CancellationToken)
Saves a relation between the current item and another item.
Declaration
public Task SaveRelationAsync(string parentIdMaster, string sectionName, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | parentIdMaster | The Id of the parent item. |
string | sectionName | The name of the section that defines the relationship. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
SaveSectionAsActiveAsync(SectionPart, CancellationToken)
Saves the section part as active, setting its validation, activation status and version status to true and "Active" respectively.
Declaration
public Task<List<string>> SaveSectionAsActiveAsync(Item.SectionPart sectionPart, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Item.SectionPart | sectionPart | The Item.SectionPart to be saved as active. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<List<string>> | A list of modified fields. |
SaveSectionAsync(SectionPart, CancellationToken)
Saves the section data of the item to the database asynchronously.
Declaration
public Task<List<string>> SaveSectionAsync(Item.SectionPart sectionPart, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Item.SectionPart | sectionPart | The Item.SectionPart of the item to be saved. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<List<string>> | A list of modified fields in the section data. |
Exceptions
Type | Condition |
---|---|
Exception | Thrown when the IdMaster of the item is invalid or undefined or the section part of the item is not loaded or the SectionDataName of the section part is not valid. |
SetVersionAsDefaultAsync(string, ItemVersion, CancellationToken)
Sets the specified version of a section as the default version for the item by name.
Declaration
public Task SetVersionAsDefaultAsync(string sectionDataName, ItemVersion version, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | sectionDataName | The name of the section. |
ItemVersion | version | The version to set as default. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
SetVersionAsDefaultByCultureAsync(string, string, CancellationToken)
Sets the specified version of a section as the default version for the item by culture.
Declaration
public Task SetVersionAsDefaultByCultureAsync(string sectionDataName, string versionCulture, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | sectionDataName | The name of the section. |
string | versionCulture | The culture of the version to set as default. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
UpdateDateModifiedAsync(CancellationToken)
Updates the date modified field of this item.
Declaration
public Task UpdateDateModifiedAsync(CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |
UpdateLabelAsync(string, CancellationToken)
Updates the label of the current item.
Declaration
public Task UpdateLabelAsync(string label, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | label | The new label to set. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |
Exceptions
Type | Condition |
---|---|
Exception | Thrown when the IdMaster is invalid or undefined or when the label is null or empty. |
UpdateStatusAsync(ItemStatus, CancellationToken)
Updates the status of this item.
Declaration
public Task UpdateStatusAsync(ItemStatus status, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
ItemStatus | status | The new ItemStatus for the item. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task | A Task representing the asynchronous operation. |