In my device reservation app, each event must be validated to ensure that the selected
device is available for the specified time range in the database. Custom editor with validation does not work in this case because we need to check the combination of
device, start time, and end time together rather than validating them individually.
I’m considering using OnPopupClose to either save the event or reopen the editor with an error message if validation fails. Is this the right approach?
public async Task OnPopupClose(PopupCloseEventArgs<Schedule> args)
{
if (args.Type == PopupType.Editor)
{
if (IsValidated(args.Data)
await _scheduler?.SaveEventAsync(args.Data)!;
else
{
AlertService.ShowAlert("Fix an error. Blah Blah");
await _scheduler?.OpenEditorAsync(args.Data, args.CurrentAction);
}