예제 #1
0
 public static BusinessRule <ShoppingCart> CanSetShippingAddress()
 {
     return(new BusinessRule <ShoppingCart>(
                "Cannot set shipping address!",
                rule =>
     {
         rule.AddCheck(ShoppingCartSpecifications.IsActive, "Shopping cart is deactivated!");
         rule.AddCheck(ShoppingCartSpecifications.IsInStatus(ShoppingCartStatus.Open), "Shipping address cannot be set anymore!");
     }));
 }
예제 #2
0
 public static BusinessRule <ShoppingCart> CanCancel()
 {
     return(new BusinessRule <ShoppingCart>(
                "Shopping cart cannot be cancelled!",
                rule =>
     {
         rule.AddCheck(ShoppingCartSpecifications.IsActive, "Shopping cart is deactivated!");
         rule.AddCheck(ShoppingCartSpecifications.IsInStatus(ShoppingCartStatus.Cancelled), "Shopping cart is already cancelled!");
         rule.AddCheck(
             ShoppingCartSpecifications.IsInStatus(ShoppingCartStatus.Ordered)
             .Or(ShoppingCartSpecifications.IsInStatus(ShoppingCartStatus.Open)),
             $"Cannot cancel shopping cart in current status!");
     }));
 }