Interface ITrinityResource
The interface of TrinityResource<TPrimaryKeyType>.
public interface ITrinityResource
Properties
Actions
The actions available for the resource.
List<object> Actions { get; }
Property Value
BulkActions
The bulk actions available for the resource.
List<object> BulkActions { get; }
Property Value
CanCreate
Whether the user can Create a new record in the resource or not.
bool CanCreate { get; }
Property Value
CanDelete
Whether the user can Delete records from the resource or not.
bool CanDelete { get; }
Property Value
CanUpdate
Whether the user can Update a record in the resource or not.
bool CanUpdate { get; }
Property Value
CanView
Whether the user can View the resource or not.
bool CanView { get; }
Property Value
Fields
The fields displayed by the resource
[JsonIgnore]
Dictionary<string, object> Fields { get; }
Property Value
Label
the singular displayable label of the resource.
string? Label { get; }
Property Value
PluralLabel
the plural displayable label of the resource.
string? PluralLabel { get; }
Property Value
Methods
Create()
Creates a new record in the Database based on the given Fields.
Task<object?> Create()
Returns
Delete()
Deletes all the records from the Database based on the sent keys.
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.
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.
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.
Task<IPaginator?> GetTableData()
Returns
- Task<IPaginator>
IPaginator of all the records retrieved from the Database
HandleAction(ITrinityAction, Dictionary<string, object?>, List<string>)
Handle and Execute the action given.
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
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.
Task Setup()
Returns
Update()
Updates the given record in the Database with the given Fields.
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).
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.