Documentation

Store

The custom card Store allows for key value pairs to be associated with custom cards. Please keep in mind that the value for customPortletUniqueId as part of the API model will be different for each instance of a custom card. If you wish to share data across multiple instances then you can hard code your own unique global ID into the code. 

Read Method

Syntax:

public T Read<T>(int customPortletUniqueId, string key)

Parameters:

Parameter Type Description
customPortletId int The custom card id
key string The key of the stored item

Return value:

Type Description
T A generic type containing the stored item
 

Examples:

@{
    var userCount = this.Store.Read<int>(Model.CustomPortletUniqueId, "user-count-key");
}

ReadAll Method

Syntax:

public IEnumerable<T> ReadAll<T>(int customPortletUniqueId)

Parameters:

Parameter Type Description
customPortletId int The custom card id

Return value:

Type Description
IEnumerable<T> A dynamic object containing the stored item
 

Examples:

@{
    var dataList = this.Store.ReadAll<dynamic>(this.Model.CustomPortletUniqueId);
}


Write Method

Syntax:

public void Write(int customPortletUniqueId, string key, string value)

Parameters:

Parameter Type Description
customPortletId int The custom card id
key string The key of the item to store
value string The value to store

Return value:

void

Examples:

@{
    var userCount = this.Api.User.GetAll().Where(user => user.LastName.StartsWith("Smi")).ToList().Count;
    this.Store.Write(this.Model.CustomPortletUniqueId, "user-count-key", userCount);
}