I am developing a hotel / billing registration application in ASP.Net using an entity structure. When it comes to creating an account for the registrant, my client has a lot of stupid criteria. Instead of a billing system for one bed (fairly standard ..), the client may be charged a different amount depending on their age, the specific dates they attend, the type of room (double bed, single bed, etc.) or a conference, on which they are present, or all four ...
Here is my chart: 
As a relatively young coder, I feel like I'm missing something, somewhere along the Rule table. What I'm trying to do allows the administrator to create any number of ConditionalStatements ("Age> 5" or "Age <10", where "Age" is Statement.Value, '>' is Condition.Value, and "5" is this is ConditionalStatement.Value) and bind any number of them together, thus creating a "Rule". Then the administrator will associate the rule with various RateSchedules, and then the application will be able to generate an account for any client registered for the stay.
I feel that I am on the right track and that most of this solution will work in every way that I need, but something does not seem to be right. I have two questions related to the creation of the "Rules".
What am I doing wrong, how far does the βrule designβ go? It feels wrong for me to generate a new RuleSet.ID every time the administrator wants to create a new rule. Should I do this programmatically? Should I completely rethink this rule process?
From an Entity Framework / scaffolding point of view, what's the best way for me to add new rules in db? Default scaffolding allows me to insert one row at a time, but to create a rule, I need to associate RuleSet.ID with several ConditionalStatement.IDs, but I cannot figure out how to do this intuitively with EF scaffolding ..
Any pointers in the right direction are highly appreciated! Thanks:)
EDIT: I ended up redesigning based on the answers to my question, but during the study I came across the Microsoft business rules engine: http://msdn.microsoft.com/en-us/library/aa561216.aspx as well as the math expression evaluator: http : //ncalc.codeplex.com/ Just in case, someone else will find this question in the future, and these links may help. Thanks for helping everyone!
source share