Use-Case-NET / RequestR

A lightweight library for the Business Layer for processing requests coming from Presentation Layer.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RequestR - Getting Started

1) Create the Request, Response and Use Case classes

The request and the response can be any C# classes.

public class PresentProductsRequest
{
}

public class PresentProductsResponse
{
}

The use case must implement the IUseCase interface.

internal class PresentProductsUseCase : IUseCase<PresentProductsRequest, PresentProductsResponse>
{
    public Task<PresentProductsResponse> Execute(PresentProductsRequest request, CancellationToken cancellationToken)
    {
        // Return the list of products.
    }
}

Note: The response class is optional, it may be missing if the use case has nothing to return.

2) Create the Request Bus and register the Use Case

RequestBus requestBus = new RequestBus();
requestBus.RegisterUseCase<PresentProductsUseCase>();

3) Send a new Request

PresentProductsRequest request = new PresentProductsRequest();
PresentProductsResponse response = requestBus.Process<PresentProductsRequest, PresentProductsResponse>(request);

About

A lightweight library for the Business Layer for processing requests coming from Presentation Layer.

License:GNU General Public License v3.0


Languages

Language:C# 100.0%