Skip to content

Business Rules

Charles Solar edited this page Jun 13, 2018 · 4 revisions

Business Exceptions

Business rules are defined in entity methods - such as this one defined in Product.cs

public void MarkReordered()
{
    Rule("Reordered", x => x.ReorderMarked, "Already reordering");
    Apply<Events.ReorderMarked>(x => { x.ProductId = Id; });
}

The helper method Rule will throw a BusinessException if the expression x => x.ReorderMarked results as true. In this way we are making sure a product already marked for reordering is not marked for reordering a second time.

Rule is a helper method - you could also just throw a BusinessException if you desire

Clone this wiki locally