public void DefineSingleActionProject(RequestId requestId, StuffId stuffId, ITimeProvider provider) { // filter request IDs var time = provider.GetUtcNow(); var projectId = new ProjectId(NewGuidIfEmpty(requestId)); // generate actionId var actionId = new ActionId(Guid.NewGuid()); // make sure Stuff exists in the Inbox StuffInfo stuffInfo; if (!_aggState.StuffInInbox.TryGetValue(stuffId, out stuffInfo)) { throw DomainError.Named("unknown stuff", "Unknown stuff {0}", stuffId); } // TODO: May be able to use this to change the stuff description and then let that cascade down // as both the Project AND Action Outcome in case you wanted to use a different name than from original desc // With current design it may be better to kick off a "RENAME" command or Apply Renamed event for that purpose though. //if (stuffInfo.Description != stuffDescription) //{ // Apply(new StuffDescriptionChanged(_aggState.Id, stuffId, newDescriptionOfStuff, time.GetUtcNow())); //} // TODO: Not sure if it best to just reuse existing Events and projections (probably) // or if I should create a new composite event for this new command msg. // Thinking the former, not latter is way to go. Apply(new ProjectDefined(_aggState.Id, projectId, stuffInfo.Description, ProjectType.List, time)); Apply(new ActionDefined(_aggState.Id, actionId, projectId, stuffInfo.Description, time)); //Apply(new SingleActionProjectDefined(_aggState.Id, etc.) // Archive the Stuff from the Inbox now that is has transitioned from "Stuff" to a defined "Action" Apply(new StuffArchived(_aggState.Id, stuffId, time)); }
public void DescriptionOfStuffChanged(StuffId stuffId, string newDescriptionOfStuff) { var stuff = _stuffInInbox[stuffId]; stuff.UpdateDescription(newDescriptionOfStuff); Publish(new Dumb.StuffUpdated(stuff.Freeze())); }
public ImmutableStuff(StuffId stuffId, string descriptionOfStuff, string uiKey, uint order) { StuffId = stuffId; Description = descriptionOfStuff; UIKey = uiKey; Order = order; }
public StuffInfo(StuffId id, string stuffDescription) { Enforce.NotEmpty(stuffDescription, "stuffDescription"); Id = id; Description = stuffDescription; }
// Trash vs. Archives // Archiving is an internal housekeeping process. // It is an event that happens within the system as a result of another user command. // A user doesn't "Archive" something, the system does. // A user Trashes stuff, puts stuff in their ReferenceSystem, Puts stuff In SomedayMaybe, MovesToProject, etc. // If a user Moves Stuff from the Inbox to a Project, then StuffArchived from Inbox, not StuffTrashed. // If a user wants to "View Archives" then things that were Archived by the system appear in that View. // However, if a user expressed their intent to TRASH an item, it is NOT in the "Archived Views". // The trashed stuff is still in the Event Stream, but from the user's perspective, it is GONE/TRASHED/Not visible! // This Event happens when Stuff is intentionally "trashed" by the user because they want it "out" of the system public void TrashStuff(StuffId stuffId, ITimeProvider provider) { if (!_aggState.Inbox.Contains(stuffId)) { throw DomainError.Named("no stuff", "Stuff with Id {0} not found", stuffId.Id); } Apply(new StuffTrashed(_aggState.Id, stuffId, provider.GetUtcNow())); }
public void DescriptionOfStuffChanged(StuffId stuffId, string newDescriptionOfStuff) { var oldStuff = _stuffInInbox[stuffId]; var newValue = oldStuff.WithDescription(newDescriptionOfStuff); _stuffInInbox = _stuffInInbox.SetItem(stuffId, newValue); Publish(new Dumb.StuffUpdated(newValue)); }
public void StuffPutInInbox(StuffId stuffId, string descriptionOfStuff, DateTime date) { var key = "stuff-" + Id.Id; var item = new ImmutableStuff(stuffId, descriptionOfStuff, key, _stuffOrderCounter++); _stuffInInbox = _stuffInInbox.Add(stuffId, item); // the Client Model state has changed, so publish a "Dumb" UI event // to keep the contents of the UI current with the actual state of this client model Publish(new Dumb.StuffAddedToInbox(item, _stuffInInbox.Count)); }
public void ChangeDescriptionOfStuff(StuffId stuffId, string newDescriptionOfStuff, ITimeProvider time) { StuffInfo stuffInfo; if (!_aggState.StuffInInbox.TryGetValue(stuffId, out stuffInfo)) { throw DomainError.Named("unknown stuff", "Unknown stuff {0}", stuffId); } if (stuffInfo.Description != newDescriptionOfStuff) { Apply(new StuffDescriptionChanged(_aggState.Id, stuffId, newDescriptionOfStuff, time.GetUtcNow())); } }
public void StuffTrashed(StuffId stuffId) { ImmutableStuff value; if (!_stuffInInbox.TryGetValue(stuffId, out value)) { return; } _stuffInInbox = _stuffInInbox.Remove(stuffId); Publish(new Dumb.StuffRemovedFromInbox(value, _stuffInInbox.Count)); }
public void RemoveStuff(StuffId stuffId) { StuffInfo stuffInfo; if (!_stuffInInbox.TryGetValue(stuffId, out stuffInfo)) return; _stuffInInbox.Remove(stuffInfo.Id); this.Sync(() => { listBox1.Items.Remove(stuffInfo); listBox1.Visible = listBox1.Items.Count > 0; }); }
public void RemoveStuff(StuffId stuffId) { StuffInfo stuffInfo; if (!_stuffInInbox.TryGetValue(stuffId, out stuffInfo)) { return; } _stuffInInbox.Remove(stuffInfo.Id); this.Sync(() => { listBox1.Items.Remove(stuffInfo); listBox1.Visible = listBox1.Items.Count > 0; }); }
public StuffDescriptionChanged(TrustedSystemId id, StuffId stuffId, string newDescriptionOfStuff, DateTime timeUtc) { Id = id; StuffId = stuffId; NewDescriptionOfStuff = newDescriptionOfStuff; TimeUtc = timeUtc; }
public void PutStuffInInbox(RequestId requestId, string stuffDescription, ITimeProvider provider) { var stuffId = new StuffId(NewGuidIfEmpty(requestId)); Apply(new StuffPutInInbox(_aggState.Id, stuffId, stuffDescription, provider.GetUtcNow())); }
public StuffTrashed(TrustedSystemId id, StuffId stuffId, DateTime timeUtc) { Id = id; StuffId = stuffId; TimeUtc = timeUtc; }
public TrashStuff(TrustedSystemId id, StuffId stuffId) { Id = id; StuffId = stuffId; }
public void StuffTrashed(StuffId stuffId) { MutableStuff value; if (!_stuffInInbox.TryGetValue(stuffId, out value)) return; _listOfGtdStuff.Remove(value); Publish(new Dumb.StuffRemovedFromInbox(value.Freeze(), _listOfGtdStuff.Count)); }
public void TrashStuff(StuffId stuffId) { StuffInfo stuffInfo; if (_stuffInInbox.TryGetValue(stuffId, out stuffInfo)) { listBox1.Items.Remove(stuffInfo); _stuffInInbox.Remove(stuffInfo.Id); } listBox1.Visible = listBox1.Items.Count > 0; }
public void StuffTrashed(StuffId stuffId) { ImmutableStuff value; if (!_stuffInInbox.TryGetValue(stuffId, out value)) return; _stuffInInbox = _stuffInInbox.Remove(stuffId); Publish(new Dumb.StuffRemovedFromInbox(value, _stuffInInbox.Count)); }
public void StuffPutInInbox(StuffId stuffId, string descriptionOfStuff, DateTime date) { var key = "stuff-" + Id.Id; var item = new ImmutableStuff(stuffId, descriptionOfStuff, key, _stuffOrderCounter++); _stuffInInbox = _stuffInInbox.Add(stuffId, item); // the Client Model state has changed, so publish a "Dumb" UI event // to keep the contents of the UI current with the actual state of this model Publish(new Dumb.StuffAddedToInbox(item, _stuffInInbox.Count)); }
public ChangeStuffDescription(TrustedSystemId id, StuffId stuffId, string newDescriptionOfStuff) { Id = id; StuffId = stuffId; NewDescriptionOfStuff = newDescriptionOfStuff; }
public MoveStuffToProjectClicked(StuffId[] stuffToMove, ProjectId project) { StuffToMove = stuffToMove; Project = project; }
public void StuffPutInInbox(StuffId stuffId, string descriptionOfStuff, DateTime date) { var key = "stuff-" + Id.Id; var item = new MutableStuff(stuffId, descriptionOfStuff, key); _listOfGtdStuff.Add(item); _stuffInInbox.Add(stuffId, item); Publish(new Dumb.StuffAddedToInbox(item.Freeze(), _listOfGtdStuff.Count)); }
public TrashStuffClicked(StuffId id) { Id = id; }
public MutableStuff(StuffId stuffId, string description, string uiKey) { StuffId = stuffId; Description = description; UIKey = uiKey; }
public ImmutableStuff(StuffId stuffId, string descriptionOfStuff, string uiKey) { StuffId = stuffId; Description = descriptionOfStuff; UIKey = uiKey; }
public DefineSingleActionProject(TrustedSystemId id, RequestId requestId, StuffId stuffId) { Id = id; RequestId = requestId; StuffId = stuffId; }
// Trash vs. Archives // Archiving is an internal housekeeping process. // It is an event that happens within the system as a result of another user command. // A user doesn't "Archive" something, the system does. // A user Trashes stuff, puts stuff in their ReferenceSystem, Puts stuff In SomedayMaybe, MovesToProject, etc. // If a user Moves Stuff from the Inbox to a Project, then StuffArchived from Inbox, not StuffTrashed. // If a user wants to "View Archives" then things that were Archived by the system appear in that View. // However, if a user expressed their intent to TRASH an item, it is NOT in the "Archived Views". // The trashed stuff is still in the Event Stream, but from the user's perspective, it is GONE/TRASHED/Not visible! // This Event happens when Stuff is intentionally "trashed" by the user because they want it "out" of the system public void TrashStuff(StuffId stuffId, ITimeProvider provider) { if (!_aggState.Inbox.Contains(stuffId)) throw DomainError.Named("no stuff", "Stuff with Id {0} not found", stuffId.Id); Apply(new StuffTrashed(_aggState.Id, stuffId, provider.GetUtcNow())); }
public void MoveStuffToProject(StuffId[] stuffToMove, ProjectId projectId, ITimeProvider provider) { ProjectInfo projectInfo; if (!_aggState.Projects.TryGetValue(projectId, out projectInfo)) { throw DomainError.Named("unknown-project", "Unknown project {0}", projectId); } var dateTime = provider.GetUtcNow(); foreach (var stuffId in stuffToMove) { StuffInfo stuffInfo; if (!_aggState.StuffInInbox.TryGetValue(stuffId, out stuffInfo)) { throw DomainError.Named("unknown-stuff", "Unknown stuff {0}", stuffId); } Apply(new StuffArchived(_aggState.Id, stuffId, dateTime)); Apply(new ActionDefined(_aggState.Id,new ActionId(Guid.NewGuid()), projectId, stuffInfo.Description, dateTime)); } }
public StuffPutInInbox(TrustedSystemId id, StuffId stuffId, string stuffDescription, DateTime timeUtc) { Id = id; StuffId = stuffId; StuffDescription = stuffDescription; TimeUtc = timeUtc; }