With the facades over the connection built in a reliable manner, the next step is to encapsulate the business logic in a series of services. By doing so, we can reuse this same logic for web applications, client applications, as well as mobile applications.
Services have no rhyme or reason in format. The idea here is to create an interface, along with utilizing Criteria
and Presentation Model
objects for shuttling data in and out of the service. This separates the OR/M code from our overall business logic. Ultimately, when we get to the point of authoring unit tests, we will also be able to mock the IRepository<T>
interfaces and return real Presentation Models for assertions.
Here is an example of a basic service:
The use of the above service is to allow access to each client’s account and assist in provisioning it. The overall take away from this is two fold: