We are working on project where we have to manage these conditions. i.e.:
A User can save an order under these conditions:
- User has permission "SaveOrder"
- Order is in state "shipped"
- Online Shop is opened.
This condition is for example - I would like to point out, that we have three conditions from different areas(role and permissions, inner state of object order and state of another domain object).
In a previous project we used this code:
public static bool CanSaveOrder(Order order)
{
return
CurrentPrincipal.HasPermission(Permissions.SaveOrder) &&
order.State == States.Shipped &&
OnlineShop.IsOpen();
}
But I feel that there can be a more elegant/dynamic solution.
I have read something about a "business role engine". Is it a right way to manage this condition?
We are building large enterprise system and sometimes our PM reproaches us for having to deploy new version of application because of change some simple rule. So I am looking for some solution, if exists. What do you think? And is there any good start to learning about roles engine. we developed in C# and asp.net. And just to be clear: I am VERY big fan of YAGNI but sometimes I feel that we have to deploy our older systems too often(i.e. small changes of tax rate).
– Marek Jun 15 '13 at 15:11