Using the Domain concepts and Prebuilt Queries of Highway.Data, we have included a basic RESTful base class for your ApiControllers. This feature is very easy to use, simply inherit from
BaseRestApiController. That base class has two constructor requirements:
IDomainRepositoryFactorythis class comes from Highway.Data and is already registered with our IoC.
RestfulOperationsthis is a FLAGS enumeration that lets you control how the base class behaves.
An implementation controller would look like this:
1 2 3 4 5 6 7 8 9 10
This class would support all five of our pre-built functions, because it passed
RestfulOperations.All, these are:
- GetAll – This is the default get with no
idand returns ALL Drivers
- GetOne – This returns one driver, by
- Put – Accepts a
PUTverb and updates a singular Driver. Uses
CopyEntityValuesabove to control what can be updated.
- Delete – Deletes a Driver by
- Post – Accepts a
POSTverb and inserts a singular Driver.
Importantly this enums is FLAGS based, and as such the values can be OR’ed together. For instance, if you wanted to just support GetOne and Post you could change the line above to:
There are some logical pre-built combinations already supported in the enum, which is defined as follows:
1 2 3 4 5 6 7 8 9 10 11 12