Interface IFormService
Service for managing forms, which are collections of controls used for data entry and display. Provides methods for getting and validating form data, updating data, and validating control contexts.
Namespace: DataWeb.Data
Assembly: DataWeb.Core.dll
Syntax
public interface IFormService
Methods
GetFormAsync(string, string, CancellationToken)
Gets a single form by its name and culture.
Declaration
Task<Form> GetFormAsync(string name, string culture = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the form to retrieve. |
string | culture | The culture to retrieve the form for. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<Form> | A Form object representing the retrieved form. |
GetFormDefaultValuesAsync(Form, IUser, string, NavigationContext, CancellationToken)
Gets the default values of a form's controls.
Declaration
Task<Dictionary<string, object>> GetFormDefaultValuesAsync(Form form, IUser user, string itemId = null, NavigationContext navigationContext = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Form | form | The Form to get the default values for. |
IUser | user | The IUser requesting the form. |
string | itemId | The Id of the item the form relates to. |
NavigationContext | navigationContext | The NavigationContext for the form. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<Dictionary<string, object>> | A Dictionary<TKey, TValue> containing the default values of the form's controls. |
GetFormValuesAsync(Form, Dictionary<string, object>, IUser, string, NavigationContext, Control, CancellationToken)
Gets the values of a form's controls.
Declaration
Task<Dictionary<string, object>> GetFormValuesAsync(Form form, Dictionary<string, object> sectionData, IUser user, string itemId = null, NavigationContext navigationContext = null, Control parentControl = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Form | form | The Form to get the values for. |
Dictionary<string, object> | sectionData | The section data for the form. |
IUser | user | The IUser requesting the form. |
string | itemId | The Id of the item the form relates to. |
NavigationContext | navigationContext | The NavigationContext for the form. |
Control | parentControl | The parent Control for the form. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<Dictionary<string, object>> | A Dictionary<TKey, TValue> containing the values of the form's controls. |
GetFormsAsync(string, CancellationToken)
Gets all forms for the specified culture.
Declaration
Task<IEnumerable<Form>> GetFormsAsync(string culture = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | culture | The culture to retrieve the forms for. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<IEnumerable<Form>> | An IEnumerable<T> of Form objects representing the retrieved forms. |
UpdateDataWithFormAsync(Dictionary<string, object>, Form, List<ProvidedValue>, IUser, string, NavigationContext, Control, CancellationToken)
Updates the data for the provided section with the values from the form and provided values.
Declaration
Task UpdateDataWithFormAsync(Dictionary<string, object> sectionData, Form form, List<Form.ProvidedValue> providedValues, IUser user, string itemId = null, NavigationContext navigationContext = null, Control parentControl = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Dictionary<string, object> | sectionData | The data for the section to update. |
Form | form | The Form containing the controls for the data. |
List<Form.ProvidedValue> | providedValues | The values provided for the form. |
IUser | user | The IUser who is updating the data. |
string | itemId | The Id of the item to update (if applicable). |
NavigationContext | navigationContext | The NavigationContext for the form (if applicable). |
Control | parentControl | The parent Control for the section data (if applicable). |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task | A task representing the asynchronous update operation. |
ValidateControlContextAsync(string, string, string, IUser, CancellationToken)
Validates the context of a control against the specified user's permissions.
Declaration
Task<ValidateControlContextResult> ValidateControlContextAsync(string formName, string controlFullName, string controlType, IUser user, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | formName | The name of the form containing the control. |
string | controlFullName | The full name of the control. |
string | controlType | The type of the control. |
IUser | user | The IUser to validate the control context against. |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<ValidateControlContextResult> | A task representing the asynchronous validation operation. The result of the task is a ValidateControlContextResult object containing the result of the validation. |
ValidateFormAsync(Form, List<ProvidedValue>, IUser, Dictionary<string, object>, string, NavigationContext, string, CancellationToken)
Validates the entire form against the provided values and returns a list of validation errors.
Declaration
Task<List<ValidationError>> ValidateFormAsync(Form form, List<Form.ProvidedValue> providedValues, IUser user, Dictionary<string, object> sectionData, string itemId = null, NavigationContext navigationContext = null, string prefix = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
Form | form | The Form to validate. |
List<Form.ProvidedValue> | providedValues | The values provided for the form. |
IUser | user | The IUser who is validating the form. |
Dictionary<string, object> | sectionData | The data for the form sections. |
string | itemId | The Id of the item to validate (if applicable). |
NavigationContext | navigationContext | The NavigationContext for the form (if applicable). |
string | prefix | The prefix for the controls in the form (if applicable). |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<List<ValidationError>> | A task representing the asynchronous validation operation. The result of the task is a list of validation errors. |