Class TrinityResource<TPrimaryKeyType>
The Trinity Resource.
public abstract class TrinityResource<TPrimaryKeyType> : CanMakeComponent, ITrinityResource
Type Parameters
- Inheritance
-
TrinityResource<TPrimaryKeyType>
- Implements
- Derived
- Inherited Members
Properties
Actions
The actions available for the resource.
public List<object> Actions { get; }
Property Value
BottomWidgets
Get the bottom widgets displayed by the resource.
public List<object> BottomWidgets { get; }
Property Value
BulkActions
The bulk actions available for the resource.
public List<object> BulkActions { get; }
Property Value
CanCreate
Whether the user can Create a new record in the resource or not.
public virtual bool CanCreate { get; }
Property Value
CanDelete
Whether the user can Delete records from the resource or not.
public virtual bool CanDelete { get; }
Property Value
CanUpdate
Whether the user can Update a record in the resource or not.
public virtual bool CanUpdate { get; }
Property Value
CanView
Whether the user can View the resource or not.
public virtual bool CanView { get; }
Property Value
Columns
Get the columns displayed by the resource.
public List<object> Columns { get; }
Property Value
Fields
Gets the fields of the form.
public Dictionary<string, object> Fields { get; }
Property Value
- Dictionary<string, object>
The fields of the form.
Icon
The Navigation icon for the resource.
public virtual string? Icon { get; }
Property Value
IsCreateRequest
Whether the current request is a Create request or not.
protected bool IsCreateRequest { get; init; }
Property Value
IsUpdateRequest
Whether the current request is a Update request or not.
protected bool IsUpdateRequest { get; init; }
Property Value
Label
the singular displayable label of the resource.
public virtual string? Label { get; init; }
Property Value
Name
The resource name.
public string Name { get; init; }
Property Value
PluralLabel
the plural displayable label of the resource.
public virtual string? PluralLabel { get; init; }
Property Value
PrimaryKeyColumn
The Table primary key, to be used when Querying the records from the Table.
public virtual string PrimaryKeyColumn { get; }
Property Value
Schema
Get the schema displayed by the resource.
public List<object> Schema { get; }
Property Value
ShowGridlines
Enabling showGridlines displays borders between Table cells.
public virtual bool ShowGridlines { get; }
Property Value
StripedRows
Alternating rows are displayed when stripedRows property is present.
public virtual bool StripedRows { get; }
Property Value
Table
The table associated with the resource in the Database.
protected virtual string? Table { get; init; }
Property Value
TitleColumn
The column to be used to get the single value , that should be used to represent the resource when being displayed.
public abstract string TitleColumn { get; }
Property Value
TopWidgets
Get the top widgets displayed by the resource.
public List<object> TopWidgets { get; }
Property Value
TrinityForm
A reference to the current TrinityForm
protected TrinityForm TrinityForm { get; }
Property Value
TrinityTable
A reference to the current TrinityTable
protected TrinityTable TrinityTable { get; }
Property Value
Methods
AfterCreate(IReadOnlyDictionary<string, object?>, TPrimaryKeyType?)
Fired after inserting a new record to the Resource table.
protected virtual Task AfterCreate(IReadOnlyDictionary<string, object?> form, TPrimaryKeyType? insertedKey)
Parameters
form
IReadOnlyDictionary<string, object>The validated form used to insert the new record.
insertedKey
TPrimaryKeyTypeThe new inserted record Id.
Returns
AfterDelete(IReadOnlyList<string>, bool)
Fired after deleting the given ids from the Resource table.
protected virtual Task AfterDelete(IReadOnlyList<string> deletedIds, bool isDeletedSuccessfully)
Parameters
deletedIds
IReadOnlyList<string>The given ids used to delete the records.
isDeletedSuccessfully
boolWhether the delete was successful or not.
Returns
AfterUpdate(IReadOnlyDictionary<string, object?>, IReadOnlyDictionary<string, object?>?)
Fired after updating the record in the Resource table.
protected virtual Task AfterUpdate(IReadOnlyDictionary<string, object?> oldRecord, IReadOnlyDictionary<string, object?>? newRecord)
Parameters
oldRecord
IReadOnlyDictionary<string, object>The old record value before update.
newRecord
IReadOnlyDictionary<string, object>the new record value after update.
Returns
BeforeCreate(ref Dictionary<string, object?>)
Fired before inserting a new record to the Resource table.
protected virtual Task BeforeCreate(ref Dictionary<string, object?> form)
Parameters
form
Dictionary<string, object>The given form after validation.
Returns
BeforeDelete(ref List<string>)
Fired before deleting the given ids from the Resource table.
protected virtual Task BeforeDelete(ref List<string> idsToBeDeleted)
Parameters
Returns
BeforeUpdate(ref Dictionary<string, object?>, IReadOnlyDictionary<string, object?>)
Fired before updating the given record with the form.
protected virtual Task BeforeUpdate(ref Dictionary<string, object?> form, IReadOnlyDictionary<string, object?> record)
Parameters
form
Dictionary<string, object>The validated form used to update the record.
record
IReadOnlyDictionary<string, object>The current record in the Database.
Returns
Create()
Creates a new record in the Database based on the given Fields.
public virtual Task<object?> Create()
Returns
Delete()
Deletes all the records from the Database based on the sent keys.
public virtual Task<object?> Delete()
Returns
- Task<object>
A fresh GetTableData()
GetEditData()
Retrieves the record to be edited from the Database based on the given id in RouteValues.
public virtual Task<IDictionary<string, object?>?> GetEditData()
Returns
- Task<IDictionary<string, object>>
The record to be edited from the Database.
GetRelationData()
Retrieves all the records from the Database based on the giving column key in Query.
public virtual Task<IActionResult> GetRelationData()
Returns
- Task<IActionResult>
A list of all the related records.
GetTableData()
Retrieves all the records from the Database based on the Columns given.
public virtual Task<IPaginator?> GetTableData()
Returns
- Task<IPaginator>
IPaginator of all the records retrieved from the Database
GetTrinityForm()
Get the form displayed by the resource.
protected virtual TrinityForm GetTrinityForm()
Returns
- TrinityForm
A new TrinityForm
GetTrinityTable()
Get the Table displayed by the resource.
protected virtual TrinityTable GetTrinityTable()
Returns
- TrinityTable
A new TrinityTable
HandleAction(ITrinityAction, Dictionary<string, object?>, List<string>)
Handle and Execute the action given.
public Task<object> HandleAction(ITrinityAction action, Dictionary<string, object?> form, List<string> primaryKeys)
Parameters
action
ITrinityActionThe ITrinityAction given in the request.
form
Dictionary<string, object>The form values sent with the action, if any.
primaryKeys
List<string>The keys of the records to apply the action to.
Returns
OnIndexQuery(ref Query)
Executes before executing resource index page query.
protected virtual void OnIndexQuery(ref Query query)
Parameters
query
QueryThe query being executed.
Setup()
Setup is being called on each request, once the Resource is resolved from the The IServiceProvider. Can be used to resolve extra Services or do some logic before using the Resource.
public virtual Task Setup()
Returns
Update()
Updates the given record in the Database with the given Fields.
public virtual Task<object?> Update()
Returns
ValidateRequest(Dictionary<string, JsonElement>?, Dictionary<string, object>?)
Validate the upcoming request based on the JsonFrom sent , and the registered (Fields , or any given custom fields).
public virtual Task<Dictionary<string, object?>?> ValidateRequest(Dictionary<string, JsonElement>? jsonForm = null, Dictionary<string, object>? fields = null)
Parameters
jsonForm
Dictionary<string, JsonElement>The JsonFrom sent.
fields
Dictionary<string, object>The registered Fields in the resource, or custom fields.
Returns
- Task<Dictionary<string, object>>
Null if validation failed, otherwise the validated values.