public async Task <TResponse> Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate <TResponse> next)
        {
            if (request is IValidatable validatable)
            {
                if (validatable is BaseCommand command)
                {
                    command.Validate();

                    if (command.Invalid)
                    {
                        foreach (var notify in command.Notifications)
                        {
                            _notification.Add(notify.Message);
                        }

                        return(default(TResponse));
                    }
                }
            }

            if (next != null)
            {
                var result = await next();

                return(result);
            }

            return(default(TResponse));
        }
示例#2
0
 protected void AddNotification(string notification)
 {
     Notification.Add(notification);
 }