RecroGridDynTEntityOnUpdateAsync Method

Modifying an entity or creating a new entry.

Definition

Namespace: Recrovit.RecroGridFramework
Assembly: Recrovit.RecroGrid (in Recrovit.RecroGrid.dll) Version: 6.4.0.24.0124.1
C#
protected virtual Task<bool> OnUpdateAsync(
	IRGDataContext context,
	TEntity dataRec,
	RGClientParam param,
	RGUIMessages messages
)

Parameters

context  IRGDataContext
The context.
dataRec  TEntity
The data record.
param  RGClientParam
A kliensről érkező paraméterek.
messages  RGUIMessages
A kliensnek küldendő üzenetek.

Return Value

TaskBoolean
true if the modification succeeded, otherwise false.

Remarks

By default, if the entity implements the IRecroGridUpdate interface, then the RecroGridUpdate(IRGDataContext, RGClientParam, RGUIMessages) method is also executed.

Example

C#
protected override async Task<bool> OnUpdateRecAsync(RecroTrack tracking, Person dataRec, RGClientParam arg, RGUIMessages messages)
{
    if (arg.IsNewEntity)
    {
        //New data entry with custom modifications
    }
    else
    {
        //Modify data entry with custom modifications
    }

    //Invoke IRecroGridUpdate
    if (!await base.OnUpdateRecAsync(tracking, dataRec, arg, messages))
    {
        return false;
    }

    if (string.IsNullOrEmpty(dataRec.FirstName))
    {
        //Error message associated with a field from the RecroDict dictionary
        messages.AddError(RecroDict.Get(RecroGridContext.HttpContext, "Person.Validation", "FirstName"), Alias2ClientName("FirstName"));
    }
    if (!ExternalValidation(dataRec))
    {
        messages.AddError("Custom error message!");
    }
    return messages.ErrorCount == 0;
}

See Also