Table of Contents

Interface ITrinityResource

Namespace
AbanoubNassem.Trinity.Resources
Assembly
AbanoubNassem.Trinity.dll
public interface ITrinityResource

Properties

Actions

The actions available for the resource.

List<object> Actions { get; }

Property Value

List<object>

BulkActions

The bulk actions available for the resource.

List<object> BulkActions { get; }

Property Value

List<object>

CanCreate

Whether the user can Create a new record in the resource or not.

bool CanCreate { get; }

Property Value

bool

CanDelete

Whether the user can Delete records from the resource or not.

bool CanDelete { get; }

Property Value

bool

CanUpdate

Whether the user can Update a record in the resource or not.

bool CanUpdate { get; }

Property Value

bool

CanView

Whether the user can View the resource or not.

bool CanView { get; }

Property Value

bool

Fields

The fields displayed by the resource

[JsonIgnore]
Dictionary<string, object> Fields { get; }

Property Value

Dictionary<string, object>

Label

the singular displayable label of the resource.

string? Label { get; }

Property Value

string

PluralLabel

the plural displayable label of the resource.

string? PluralLabel { get; }

Property Value

string

Methods

Create()

Creates a new record in the Database based on the given Fields.

Task<object?> Create()

Returns

Task<object>

The new record if it succeeded.

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 ITrinityAction

The 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

Task<object>

TrinityActionResult

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

Task

Update()

Updates the given record in the Database with the given Fields.

Task<object?> Update()

Returns

Task<object>

The updated record if it succeeded.

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.