Skip to content

Configuration options

Jon P Smith edited this page Jan 21, 2019 · 5 revisions

Configuration options

There are two main parts to the configuration: a) Validation and b) user messages.

Validation

GenericBizRunnerConfig.SaveChangesExceptionHandler

If you set this property to a method it will be called if there is an exception when SaveChanges/Async are called within the SaveChangedWithValidation (and Async) method. You method should either

  1. Return a IStatusGeneric if it handled the exception (either by returning a error message or a status message) if it successfully handled the exception.
  2. Returns null if it didn't recognise the exception/error and couldn't handle it. In that case the code will rethrow the exception and it will bubble up to the top.

GenericBizRunnerConfig.BeforeSaveChanges

If you assign a method that has the type IStatusGeneric BeforeSaveChanges(DbContext context) the BeforeSaveChanges property in the GenericBizRunnerConfig class, then it will be called just before SaveChanges/SaveChangesAsync is called. This allows you to add your own validation, logging etc. before the data is saved to the database.

Note that if the method returns a IStatusGeneric result that has errors it won't call SaveChanges/SaveChangesAsync. In that case the execution of the bushiness logic is stopped and the errors the method provided are returned.

GenericBizRunnerConfig.DoNotValidateSaveChanges

By default GenericBizRunner will validate your data before it writes it to the database. It does that because business logic might create entity classes that do not match your constraints. If you really don't use validation then you can turn this off globally for all GenericBizRunner methods by setting the DoNotValidateSaveChanges to false.

User Messaging

There are a series of strings that hold the default messages that will be returned to the user on success. It also has the default method that forms that method. You can override any of these to change the messaging.

Clone this wiki locally