Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call NotifyAsync out of a controller #144

Open
rukshanfonseka opened this issue Aug 15, 2022 · 1 comment
Open

Call NotifyAsync out of a controller #144

rukshanfonseka opened this issue Aug 15, 2022 · 1 comment

Comments

@rukshanfonseka
Copy link

Can someone let me know if it is possible to call the custom webhook's NotifyAsync outside of a MVC or WebApi controller? I already send webhooks within controllers but now also need to add NotifyAsync to a WCF callback. I cannot see how I can get access to the Web hook manager.

@rukshanfonseka
Copy link
Author

Ok after much trolling through the library code this works

// this can be used outside of a MVC or WebAPI controller
public static async Task NotifyAsync(string action, object data)
{
    var logger = CommonServices.GetLogger();
    var store = CustomServices.GetStore();
    var sender = CustomServices.GetSender(logger);
    var manager = new WebHookManager(store, sender, logger);
    var notifications = new NotificationDictionary[] { new NotificationDictionary(action, data) };
    await manager.NotifyAllAsync(notifications, null);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant