public override async Task HandleAsync(EnqueueMailCommand command, CommandContext context, CancellationToken cancellationToken)
        {
            var mailTypeDefinition = _mailTypeCatalog.GetDefinition(command.Model.MailType);

            RequireValid(mailTypeDefinition != null, c => c.Model.MailType);

            var validationContext = new MailModelValidationContext(() => Lambda.MemberPath((EnqueueMailCommand c) => c.Model))
            {
                Model     = command.Model,
                DbContext = context.DbContext,
            };

            await mailTypeDefinition !.ValidateModelAsync(validationContext, cancellationToken).ConfigureAwait(false);

            if (validationContext.ErrorCode != null)
            {
                new ServiceErrorException(validationContext.ErrorCode.Value, validationContext.ErrorArgsFactory?.Invoke());
            }

            await _mailSenderService.EnqueueItemAsync(command.Model, context.DbContext, cancellationToken).ConfigureAwait(false);
        }
 public abstract Task ValidateModelAsync(MailModelValidationContext context, CancellationToken cancellationToken);