private void OnProductReservationCancelled(ProductReservationCancelled evt) { var product = GetProduct(evt); product.Reserved -= evt.Quantity; product.LastEventNumber = evt.Metadata.EventNumber; _ctx.SaveChanges(); }
public void When_CancelProductReservationLessThanReserved_ProductReservationCanceled() { Given(InitialEvents); var command = new CancelProductReservation(id, 10); command.Metadata.CausationId = command.Metadata.CommandId; command.Metadata.CorrelationId = causationAndCorrelationId; When(command); var expectedEvent = new ProductReservationCancelled(id, 3); expectedEvent.Metadata.CausationId = command.Metadata.CommandId; expectedEvent.Metadata.CorrelationId = causationAndCorrelationId; expectedEvent.Metadata.ProcessId = command.Metadata.ProcessId; Then(expectedEvent); }
private void Apply(ProductReservationCancelled evt) { Reserved -= evt.Quantity; }