Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/erlonfs/cqrs-sample
- Owner: erlonfs
- License: mit
- Created: 2020-03-14T12:11:12.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-03-03T07:37:26.000Z (over 1 year ago)
- Last Synced: 2024-10-10T23:48:30.224Z (26 days ago)
- Language: JavaScript
- Size: 569 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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"
}
```