public void Handle(EntityCreatedEvent message) { if (!_budgetModel.IsSavingLocally) { var snapshot = _createEntityFromEvent(message).GetSnapshot(); _snapshotStore.StoreSnapshot(snapshot); } }
protected SnapResult Snap(SnapshotId snapshotId, object newSnapshot) { var currentSnapshot = _snapshotStore.GetSnapshot(snapshotId); if (ShouldUpdateSnapshot(currentSnapshot, newSnapshot)) { _snapshotStore.StoreSnapshot(snapshotId, newSnapshot); return(SnapResult.SnapshotUpdated(currentSnapshot, newSnapshot)); } if (currentSnapshot == null) { return(SnapResult.SnapshotDoesNotExist(newSnapshot)); } return(_snapshotComparer.CompareSnapshots(currentSnapshot, newSnapshot) ? SnapResult.SnapshotsMatch(currentSnapshot, newSnapshot) : SnapResult.SnapshotsDoNotMatch(currentSnapshot, newSnapshot)); }
public void Handle(EntityUpdatedEvent message) { if (!_budgetModel.IsSavingLocally) { var snapshot = _snapshotStore.GetSnapshot <TSnapshot>(message.EntityID); TEntity entity; if (snapshot != null) { entity = _createEntityFromSnapshot(snapshot); } else { entity = _repository.MaterializeNewEntityCopy(message.EntityID); } entity.ReplayEvents(message.Yield()); snapshot = entity.GetSnapshot(); _snapshotStore.StoreSnapshot(snapshot); } }
protected SnapResult Snap(SnapshotId snapshotId, object newSnapshot) { var currentSnapshot = _snapshotStore.GetSnapshot(snapshotId); var areSnapshotsEqual = currentSnapshot != null && _snapshotComparer.CompareSnapshots(currentSnapshot, newSnapshot); if (!areSnapshotsEqual && _snapshotUpdateDecider.ShouldUpdateSnapshot()) { _snapshotStore.StoreSnapshot(snapshotId, newSnapshot); return(SnapResult.SnapshotUpdated(currentSnapshot, newSnapshot)); } if (currentSnapshot == null) { return(SnapResult.SnapshotDoesNotExist(newSnapshot)); } return(areSnapshotsEqual ? SnapResult.SnapshotsMatch(currentSnapshot, newSnapshot) : SnapResult.SnapshotsDoNotMatch(currentSnapshot, newSnapshot)); }