Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/erlonfs/cqrs-sample

Projeto de exemplo do pattern Command Dispatcher
https://github.com/erlonfs/cqrs-sample

Last synced: 4 days ago
JSON representation

Projeto de exemplo do pattern Command Dispatcher

Awesome Lists containing this project

README

        

# Command Query Responsibility Segregation
Projeto de exemplo do pattern CQRS

```cs
using System.Threading.Tasks;
using System.Web.Mvc;

namespace Sample.CQRS.MVC.Controllers
{
public class HomeController : Controller
{
private readonly ICommandDispatcher _commandDispatcher;
private readonly IQueryExecutor _queryExecutor;

public HomeController(ICommandDispatcher commandDispatcher,
IQueryExecutor queryExecutor)
{
_commandDispatcher = commandDispatcher;
_queryExecutor = queryExecutor;
}

public async Task Index()
{
var command = new CreateUserCommand("erlon.souza", "MyStrong(!)Pass");
await _commandDispatcher.DispatchAsync(command);

var query = new GetUserQuery("erlon.souza", "yourStrong(!)PassWord");
var result = await _queryExecutor.ExecuteAsync(query);

return Json(result, JsonRequestBehavior.AllowGet);
}
}
}
```

Resultado

```js
// 20200315181542
// http://localhost:55860/
{
"Name": "erlon.souza",
"Password": "yourStrong(!)PassWord"
}
```