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?