-
Notifications
You must be signed in to change notification settings - Fork 44
Web Api to Commands
Charles Solar edited this page Jun 13, 2018
·
2 revisions
It's servicestack's job to take requests and send domains through RabbitMq to the domain endpoint. An example service such as
[Api("Catalog")]
[Route("/catalog/products", "POST")]
public class AddProduct : DomainCommand
{
public Guid ProductId { get; set; }
public string Name { get; set; }
public int Price { get; set; }
public Guid CatalogBrandId { get; set; }
public Guid CatalogTypeId { get; set; }
}
Which is converted into a domain command via the service handler here
public Task Any(Services.AddProduct request)
{
return _bus.CommandToDomain(new Commands.Add
{
ProductId = request.ProductId,
CatalogBrandId = request.CatalogBrandId,
CatalogTypeId = request.CatalogTypeId,
Name = request.Name,
Price = request.Price,
});
}