I have a website built using ASP.NET MVC3 which is layered as follows:
- ProjectName.Shared (model + service contracts)
- ProjectName.Infrastructure
- ProjectName.Data
- ProjectName.Data.Sql
- ProjectName.Managers (Business layer)
- ProjectName.Services (WCF services)
- ProjectName.UI.Main (ASP.NET MVC3 application)
This is actually the structure I recently came up with after some refactoring. Unfortunately, there isn't complete separation between the UI and my business layer so this area could use some more refactoring - which I cannot do right now because I'm on a tight deadline.
As for now, my client has requested some new features which involve sending emails to users after some events happen. The way the website currently sends emails is by using the Postal library which is doing great so far. That happens from within the MVC web application which is different from the case I have for the new features...
The Problem:
I have the case where I need to let a private method inside my business layer to send out the emails to users. The reason why I cannot do that inside an Action method is because there are many code-paths that eventually end up calling this private method. So it's not really specific to one Action method.
Proposed Solution:
What I have in mind is to create an EmailsController which I can call its method through HTTP-POST calls from within my business layer. I would then pass on the parameters needed to send the email through the arguments of the Action method.
But I do find this solution to be kinda flawed and hacky. So I would really like to hear some thoughts on how to approach this problem.