I like the idea of splitting the command request , but I canโt see how to use it in the action of the MVC controller, which adds the entity, and after adding it, a new object identifier is required.
For example, in the simplified example below, a service is used to create a new item:
public ActionResult Assign(AssignViewModel viewModel) { var newItem = _AssignItemService.AssignItem(viewModel.ItemName, viewModel.ItemValue); return RedirectToAction("ListItem", new {id = newItem.Id); }
But when I redirect to the action that will display the new item, I need to know the identifier of the newly created item so that it can be retrieved from the database. Therefore, I must ask the service to return the newly created element (or at least its identifier).
In pure CQS, the command has no return value, so the above pattern is not valid.
Any advice gratefully received.
source share