Inter module communication I have two modules, Notification which basically contains SignalR hubs and CoreSetup which contains core setup logic in it.

I have a class in CoreSetup module which keeps track of employee location . I want SignalR hubs to be notified and those locations to be on MAP when new data are inserted through Web API. 
I don't want CoreSetup module to have dependency on SignalR module.
This is what I have done currently.

[Route("api/salesman-location")]
[ApiController]
public class SalesmanLocationController : BaseController
{
    private readonly SalesmanLocationService _salesmanLocationService;
    private readonly IHubContext&lt;ChatHub&gt; _hubContext;

    public SalesmanLocationController(SalesmanLocationService salesmanLocationService,IHubContext&lt;ChatHub&gt; hubContext)
    {
        _salesmanLocationService = salesmanLocationService;
        _hubContext = hubContext;
    }

    [Route("save")]
    [HttpPost]
    public IActionResult save([FromBody]List&lt;SalesmanLocationDto&gt; datas)
    {
        try
        {
            _hubContext.Clients.All.SendAsync("SalesManLocationfromHub", datas);
            _salesmanLocationService.save(datas);
            return Ok();
        }
        catch (CustomException ex)
        {
            return ApiResponse.getErrorResponseJson(ex.Message);
        }
        catch (Exception ex)
        {
            return ApiResponse.getErrorResponseJson("Failed to save data.");
        }
    }
}


It works pretty well but I have some logic inside save() method of SalesmanLocationService . It would be great if hub can subscribe to save() method of SalesmanLocationService without  SalesmanLocationService knowing anything about Hub.Under some condition, I should not broadcast data through hub.

This is how my interface of SalesmanLocationService looks like:

 public interface SalesmanLocationService
    {
        void save(List&lt;SalesmanLocationDto&gt; datas);
    }


This is the actual implementation of SalesmanLocationService

 public class SalesmanLocationServiceImpl : SalesmanLocationService
    {
        public SalesmanLocationServiceImpl()
        {
        }

        public void save(List&lt;SalesmanLocationDto&gt; datas)
        {
           foreach (var data in datas)
           {
            save(data);
           }
        }

        private void save(SalesmanLocationDto data)
        {
           if(someCondition){
             //broadcast to hub
           }
        }
    }
Its very much hard coded for that single domain type, SalesmanLocation. I would instead use some kind of event aggregation pattern. The domain fires off these events and the singalr hub listenes to these events. 

I have made a singalr library that seamlessly forwards events to signalr. Maybe it can give you some ideas

https://github.com/AndersMalmgren/SignalR.EventAggregatorProxy/wiki

Bascily with my design you would do

private void Save(SalesmanLocationDto dto) 
{
    repository.Save(dto);
    eventAggregator.Publish(new SalesmanLocationSavedEvent{ /* map data from dto */ }); 
}


Its completely decoupled and nor the domain or the signalr parts know about each other