public IHttpActionResult ChangeQuantity([FromBody] SetQuantityModel model) { var cmd = new SetProductQuantity(model.Id, model.Quantity); var product = _commandDispatcher.ExecuteCommand <ProductAggregate>(cmd); return(Ok(ProductModel.FromAggregate(product))); }
public async Task <IActionResult> SetQuantity([FromBody] SetProductQuantityModel model) { var useCase = new SetProductQuantity(model.Id, model.Quantity); var cmd = new Command <SetProductQuantity>(useCase); var product = await _commandHandler.Execute <Product>(cmd); return(Ok(ProductModel.FromAggregateRoot(product))); }
public void When_SetProductQuantitySame_NothingHappens() { Given( new ProductCreated(id, "Test Product", 2), new ProductQuantityChanged(id, 2)); var command = new SetProductQuantity(id, 2); command.Metadata.CausationId = command.Metadata.CommandId; command.Metadata.CorrelationId = causationAndCorrelationId; When(command); Then(new IEvent[] { }); }
public void When_SetProductQuantity_ProductQuantityChanged() { Given(new ProductCreated(id, "Test Product", 2)); var command = new SetProductQuantity(id, 5); command.Metadata.CausationId = command.Metadata.CommandId; command.Metadata.CorrelationId = causationAndCorrelationId; When(command); var expectedEvent = new ProductQuantityChanged(id, 5); expectedEvent.Metadata.CausationId = command.Metadata.CommandId; expectedEvent.Metadata.CorrelationId = causationAndCorrelationId; expectedEvent.Metadata.ProcessId = command.Metadata.ProcessId; Then(expectedEvent); }
internal void SetQuantity(SetProductQuantity cmd) { ChangeQuantity(cmd.Quantity); }