I have a bit of a design pattern issue. Say I have a module called "Events" which has the following class:
public class Event {
public string Name { get; set; }
public decimal Cost { get; set; }
}
Now say I have another module called "Membership" which has a dependency on this module. This is a basic membership module where if someone subscribes to a membership they will receive a discount of the cost of the events.
The problem I have is how do I get the correct event cost in the Events module taking into account the discount when the Events module has no knowledge of the Membership module.
One idea I come up with is to add a service in the Events module, e.g.:
public interface IEventCost {
decimal GetCost(Event event);
}
Then I would implement this in the Membership module. However every time I display the event's cost I would then have to inject the service and call the GetCost method passing in the event. I'm not sure I like this idea and I was wondering if there was a design pattern to handle this scenario.
I'd really appreciate the help.
Aucun commentaire:
Enregistrer un commentaire