BeforeEntityUpdate
How to Implement
API Example
using Bloqs.App.Engine.Commands;
using Bloqs.App.Engine.Commands.Before;
using Templates.SampleApp.Models;
using Templates.SampleApp.Models.Data;
namespace Templates.SampleApp.Api.Commands.Activities;
[EntityCommandHandler<Activity>]
public class BeforeActivityUpdate
: ICommandHandler<BeforeEntityUpdateCommand, BeforeEntityUpdateCommandResult>
{
public Task<BeforeEntityUpdateCommandResult> HandleAsync(
BeforeEntityUpdateCommand command,
CancellationToken cancellationToken = default
)
{
var activity = (Activity)command.DataEntities.First();
Console.WriteLine($"{AppConstants.App.Name} [API]: BeforeActivityUpdate: " + activity.Name);
if (string.IsNullOrEmpty(activity.Name))
{
throw new Exception("Invalid activity Name");
}
return Task.FromResult(BeforeEntityUpdateCommandResult.CreateSuccess());
}
}UI Example
Key Points
Last updated