private void OnResrvedProductPurchased(ReservedProductPurchased evt) { var product = GetProduct(evt); product.Reserved -= evt.Quantity; product.Quantity -= evt.Quantity; product.LastEventNumber = evt.Metadata.EventNumber; _ctx.SaveChanges(); }
public void When_PurchaseReserveProduct_NewProductHasNewQuantity() { Given(InitialEvents); var command = new PurchaseReservedProduct(id, 3); command.Metadata.CausationId = command.Metadata.CommandId; command.Metadata.CorrelationId = causationAndCorrelationId; When(command); var expectedEvent = new ReservedProductPurchased(id, 3); expectedEvent.Metadata.CausationId = command.Metadata.CommandId; expectedEvent.Metadata.CorrelationId = causationAndCorrelationId; expectedEvent.Metadata.ProcessId = command.Metadata.ProcessId; Then(expectedEvent); }
private void Apply(ReservedProductPurchased obj) { Quantity -= obj.Quantity; Reserved -= obj.Quantity; }