Design Idea - HeilOliver/Timeify GitHub Wiki

An API call always runs the same way. When an incoming message is received, the token in the header is used to check if the message is valid and a API call is allowed. The JSON content in the body is then deserialized and provided in the controller method. Of course, serialization presupposes that the method expects a certain object. After a successful method call, the corresponding usecase is called using the handle method. This method requires a request object which must implement the interface interface IUseCaseRequest<out TUseCaseResponse> and a presenter. With the usecase call this usecase is now processed. Errors are mapped via the class ApplicationError in the passed presenter. If successful, the usecase result is also stored in the presenter. The presenter can now generate an answer from the UseCase result. This answer is then provided as ActionResult. The ActionResult can then be used as an API answer.

Usecases in particular often require data and other services. Repositories and services are used for this purpose.

Repositories

are wrappers over the EntityFramework and are created according to the repository pattern. This means that usecases don't have to contain logic for database accesses like querys.

Services

are small program parts that represent functionality for certain subject areas. For example the JWT token generator can be used which generates JWT tokens. Using it as a service allows you to reuse it in different usecases.