Class InterestHelper
Base class for contact and person interest helpers. The helpers provide functionality that combines MDO list and 'what is actually selected', i.e., they combine entity subcollections with mdo lists.
Inherited Members
Namespace: SuperOffice.CRM.Entities
Assembly: SoDataBase.dll
Syntax
public abstract class InterestHelper : MDOProviderBase, ISoListProvider, ISoList, IPlugin, IEnumerable<ISoListItem>, IEnumerable
Remarks
The MDO list is available in two flavours - as the standard list, with Root and Heading items; and as a subset, containing only those rows that have corresponding link rows to the parent entity.
In both cases, the actual items in the lists are of type ISelectableListItem, an interface that inherits from ISoListItem but adds two more properties: A settable bool Selected, and a read-only DateTime LastChanged (which is automatically maintained).
The various SetItemSelection collections will accept a whole ISoList or various sub-objects of it, extract the Selected flags and update the entity data accordingly. Note that items that lose their Selected status cause immediate deletions, while new Selected items are not stored to the database until entity.Save() is called. Interests not in the incoming lists will not be touched.
Note that you cannot add new interest items through this class, only link existing interest items to a particular contact or person. Add new interests is an ordinary list-editing task, to be done through SoAdmin.
Constructors
InterestHelper(TableRowsBase, String, Int32)
Default constructor.
Declaration
protected InterestHelper(TableRowsBase selectedInterests, string tableName, int parentEntityId)
Parameters
Type | Name | Description |
---|---|---|
TableRowsBase | selectedInterests | List of the currently selected interests. This can either be a class of type ContIntRows or PersIntRows |
String | tableName | Name of the table holding the definition of the interests |
Int32 | parentEntityId |
Fields
_parentEntityId
Declaration
protected int _parentEntityId
Field Value
Type | Description |
---|---|
Int32 |
_selectedHeadingCollection
Declaration
protected List<ISoListHeading> _selectedHeadingCollection
Field Value
Type | Description |
---|---|
List<ISoListHeading> |
_selectedInterestIds
Declaration
protected Dictionary<int, TableRowBase> _selectedInterestIds
Field Value
Type | Description |
---|---|
Dictionary<Int32, TableRowBase> |
_selectedInterests
Declaration
protected TableRowsBase _selectedInterests
Field Value
Type | Description |
---|---|
TableRowsBase |
_selectedRootCollection
Declaration
protected List<ISoListItem> _selectedRootCollection
Field Value
Type | Description |
---|---|
List<ISoListItem> |
Properties
SelectedHeadingItems
Get the list of heading items that are currently selected, i.e., have link rows to the parent entity.
Declaration
public List<ISoListHeading> SelectedHeadingItems { get; }
Property Value
Type | Description |
---|---|
List<ISoListHeading> |
SelectedRootItems
Get the list of root items that are currently selected, i.e., have link rows to the parent entity.
Declaration
public List<ISoListItem> SelectedRootItems { get; }
Property Value
Type | Description |
---|---|
List<ISoListItem> |
Methods
BuildMdoCollections()
Convert rows object to ISoList collections. Fetching of the MDO list runs in the base class, here we instantiate InterestMDOListItem objects instead of the more generic ones, so that we can add the extra information (selected & date).
Declaration
protected override void BuildMdoCollections()
Overrides
CreateInterest(Int32)
Create a new link row for the given interest, using the protected _parentEntityId as the entity id. ALSO: Add to the _selectedInterests collection, since TableRowsBase does not have a public Add operator.
Declaration
protected abstract TableRowBase CreateInterest(int interestId)
Parameters
Type | Name | Description |
---|---|---|
Int32 | interestId | Interest id to link to |
Returns
Type | Description |
---|---|
TableRowBase | New row, which has already been added to the entity's link table collections |
GetInterestDate(TableRowBase)
Get the interest date from the link row (which must be castable to the correct type)
Declaration
protected abstract DateTime GetInterestDate(TableRowBase row)
Parameters
Type | Name | Description |
---|---|---|
TableRowBase | row | Row, castable to the type needed by the subclass |
Returns
Type | Description |
---|---|
DateTime | Last changed date extracted from the row |
GetInterestId(TableRowBase)
Get the interest id from the link row (which must be castable to the correct type)
Declaration
protected abstract int GetInterestId(TableRowBase row)
Parameters
Type | Name | Description |
---|---|---|
TableRowBase | row | Row, castable to the type needed by the subclass |
Returns
Type | Description |
---|---|
Int32 | Interest ID the row links to |
GetItemsAndHeadingsQuery()
Create a query for for reading the items and headings of the interest list, including any currently selected items (regardless of filtering; this is implemented in the base class). Searching is not supported.
Declaration
protected override ListTableRows.CustomSearch GetItemsAndHeadingsQuery()
Returns
Type | Description |
---|---|
ListTableRows.CustomSearch | Query for reading the items and headdings of a list. |
Overrides
IsItemSelected(Int32)
Declaration
public bool IsItemSelected(int interestId)
Parameters
Type | Name | Description |
---|---|---|
Int32 | interestId |
Returns
Type | Description |
---|---|
Boolean |
ReadItemsAndHeadings()
Read all mdo items with heading information
Declaration
protected override void ReadItemsAndHeadings()
Overrides
Refresh()
Declaration
public void Refresh()
SetItemSelection(ISelectableListItem)
Extract the 'Selected' property from the elements, and synchronize the entity's link table with the present status. Deletions are performed immediately, additions need to be saved through entity.Save() (so always do an entity.Save() anyway!)
Declaration
public void SetItemSelection(ISelectableListItem item)
Parameters
Type | Name | Description |
---|---|---|
ISelectableListItem | item | Single MDO list item |
SetItemSelection(ISoList)
Extract the 'Selected' property from all elements, and synchronize the entity's link table with the present status. Deletions are performed immediately, additions need to be saved through entity.Save() (so always do an entity.Save() anyway!)
Declaration
public void SetItemSelection(ISoList list)
Parameters
Type | Name | Description |
---|---|---|
ISoList | list | Complete MDO list, with root, heading and history items. History items are IGNORED! |
SetItemSelection(List<ISelectableListItem>)
Extract the 'Selected' property from all elements, and synchronize the entity's link table with the present status. Deletions are performed immediately, additions need to be saved through entity.Save() (so always do an entity.Save() anyway!)
Declaration
public void SetItemSelection(List<ISelectableListItem> items)
Parameters
Type | Name | Description |
---|---|---|
List<ISelectableListItem> | items | List of MDO list items |
SetItemSelection(List<ISoListItem>)
Extract the 'Selected' property from all elements, and synchronize the entity's link table with the present status. Deletions are performed immediately, additions need to be saved through entity.Save() (so always do an entity.Save() anyway!)
Declaration
public void SetItemSelection(List<ISoListItem> selectableItems)
Parameters
Type | Name | Description |
---|---|---|
List<ISoListItem> | selectableItems | List of MDO list items. Items not of (a subtype of) ISelectableListItem are quietly ignored and do no harm. |
SetItemSelection(Int32, Boolean)
Synchronize the entity's link table with the present status for the given interest. Deletions are performed immediately, additions need to be saved through entity.Save() (so always do an entity.Save() anyway!)
Declaration
public void SetItemSelection(int interestId, bool isSelected)
Parameters
Type | Name | Description |
---|---|---|
Int32 | interestId | ID of interest to add or remove |
Boolean | isSelected | New status |
Events
OnActiveInterestsChanged
Subscribe or unsubscribe to the event raised whenever the number of active interests are changed.
Declaration
public event ActiveInterestsChanged OnActiveInterestsChanged
Event Type
Type | Description |
---|---|
ActiveInterestsChanged |