public (DecrementModel model, Version version) Load(IEventstore es, Decrement command) { var model = new DecrementModel { CounterExists = _counterIds.Contains(command.CounterId), }; return(model, es.Version(command.CounterId)); }
public (CommandStatus commandStatus, Event[] events, Notification[] notifications) Execute(Decrement command, DecrementModel model) { if (model.CounterExists is false) { return(new Failure("Counter not found! Increment first."), new Event[0], new Notification[0]); } return(new Success(), new Event[] { new Decremented { CounterId = command.CounterId } }, new Notification[0]); }