// each handler is responsible for updating underlying model and make sure the aggregate looks correct from its public interface's perspective private void Handle(ChangesCommitted changesCommitted) { // update first commit datetime if required // and update last commit datetime if (!FirstCommitAtUtc.HasValue) { FirstCommitAtUtc = changesCommitted.OccurredAtUtc; } LastCommitAtUtc = changesCommitted.OccurredAtUtc; }
public void Commit(string userName, string comments, DateTime commitedAtUtc) { // describe it as an event, rather than modifying the underlying model var @event = new ChangesCommitted(Guid.NewGuid(), commitedAtUtc, Id, userName, comments); // mark this event as uncommitted, so that they can be picked up and persisted _uncommittedEvents.Add(@event); // apply this event to aggregate, which then updates the underlying model Handle(@event); }
public void CommitChanges() { var result = _client?.CommitChanges(); if (result == null) { return; } if (!result.StateChanged) { return; } _logService.Information("Sent " + BitConverter.ToString(result.State)); ChangesCommitted?.Invoke(this, new ChangesCommittedEventArgs(result.State)); }
/// <summary> /// 現在の<see cref="OperationManager"/>の状態に対して、保存処理が行われたことを通知します。 /// </summary> public void CommitChanges() { LastCommittedOperation = UndoStack.Count > 0 ? UndoStack.Peek() : null; ChangesCommitted?.Invoke(this, EventArgs.Empty); }
public void Reset() { var result = _client.Reset(); ChangesCommitted?.Invoke(this, new ChangesCommittedEventArgs(result.State)); }