Data model:
tTemplate (TemplateId int PK)
tPage (PageId int PK, TemplateId int FK)
tEmailMessage (EmailMessageId int PK, TemplateId int FK)
Requirements:
Deleting a template should be permitted only if there are no dependencies on it.
The TemplateService is responsible for deleting templates:
new TemplateService().Delete(myTemplate);
The Page and Email modules depend on the Template module, which in turn is happily unaware of these dependencies. In some setups the Page or Email module will not event be present. How would I resolve the dependency on the underlying data model? How do I get the TemplateService to start an inquiry to find out if it is ok to delete the item?
I’ve done some research on EventBrokers and Message Queues but fail to see how they alone can help me. I also fail to see how using the .net event model alone would solve this.
I'm not really looking for a way of upholding data integrity but a way of allowing for inter-service communication without causing unwanted service dependencies. I might have an implementation of the PageService where deleting the template would be ok, and where the dependancy would be resolved by setting the tPage.TemplateId to null. In other implementations I might want to create a cascading delete.