public void Unregister(EndUserId endUserId) { var latestRegistration = Registrations.LastOrDefault(); if (latestRegistration == null) { throw new ValidationException("Robot is not registered"); } latestRegistration.Apply( registration => { if (registration.EndUserId == endUserId) { var e = RobotUnregistered.Create(); Apply(e); Append(Guid.NewGuid(), RobotUnregistered.EventType, e); } else { throw new ValidationException("Robot is registered to somebody else"); } }, unregistration => throw new ValidationException("Robot is not registered") ); }