예제 #1
0
        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));
        }
예제 #2
0
        public void DescriptionOfStuffChanged(StuffId stuffId, string newDescriptionOfStuff)
        {
            var stuff = _stuffInInbox[stuffId];
            stuff.UpdateDescription(newDescriptionOfStuff);

            Publish(new Dumb.StuffUpdated(stuff.Freeze()));
        }
예제 #3
0
 public ImmutableStuff(StuffId stuffId, string descriptionOfStuff, string uiKey, uint order)
 {
     StuffId     = stuffId;
     Description = descriptionOfStuff;
     UIKey       = uiKey;
     Order       = order;
 }
예제 #4
0
        public StuffInfo(StuffId id, string stuffDescription)
        {
            Enforce.NotEmpty(stuffDescription, "stuffDescription");

            Id          = id;
            Description = stuffDescription;
        }
예제 #5
0
        // 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()));
        }
예제 #6
0
        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));
        }
예제 #7
0
        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()));
     }
 }
예제 #9
0
        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()));
            }
        }
예제 #10
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));
        }
예제 #11
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;
                });
        }
예제 #12
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;
            });
        }
예제 #13
0
 public StuffDescriptionChanged(TrustedSystemId id, StuffId stuffId, string newDescriptionOfStuff, DateTime timeUtc)
 {
     Id = id;
     StuffId = stuffId;
     NewDescriptionOfStuff = newDescriptionOfStuff;
     TimeUtc = timeUtc;
 }
예제 #14
0
        public void PutStuffInInbox(RequestId requestId, string stuffDescription, ITimeProvider provider)
        {
            var stuffId = new StuffId(NewGuidIfEmpty(requestId));

            Apply(new StuffPutInInbox(_aggState.Id, stuffId, stuffDescription, provider.GetUtcNow()));
        }
예제 #15
0
 public StuffTrashed(TrustedSystemId id, StuffId stuffId, DateTime timeUtc)
 {
     Id = id;
     StuffId = stuffId;
     TimeUtc = timeUtc;
 }
예제 #16
0
 public TrashStuff(TrustedSystemId id, StuffId stuffId)
 {
     Id = id;
     StuffId = stuffId;
 }
 public void PutStuffInInbox(RequestId requestId, string stuffDescription, ITimeProvider provider)
 {
     var stuffId = new StuffId(NewGuidIfEmpty(requestId));
     Apply(new StuffPutInInbox(_aggState.Id, stuffId, stuffDescription, provider.GetUtcNow()));
 }
예제 #18
0
        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));
        }
예제 #19
0
 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;
 }
예제 #20
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));
        }
예제 #21
0
        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));
        }
예제 #22
0
        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));
        }
예제 #23
0
 public ImmutableStuff(StuffId stuffId, string descriptionOfStuff, string uiKey, uint order)
 {
     StuffId = stuffId;
     Description = descriptionOfStuff;
     UIKey = uiKey;
     Order = order;
 }
예제 #24
0
 public ChangeStuffDescription(TrustedSystemId id, StuffId stuffId, string newDescriptionOfStuff)
 {
     Id = id;
     StuffId = stuffId;
     NewDescriptionOfStuff = newDescriptionOfStuff;
 }
예제 #25
0
        public StuffInfo(StuffId id, string stuffDescription)
        {
            Enforce.NotEmpty(stuffDescription, "stuffDescription");

            Id = id;
            Description = stuffDescription;
        }
예제 #26
0
파일: Ui.cs 프로젝트: vishal-h/btw-gtd
 public MoveStuffToProjectClicked(StuffId[] stuffToMove, ProjectId project)
 {
     StuffToMove = stuffToMove;
     Project = project;
 }
예제 #27
0
        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));
        }
예제 #28
0
파일: Ui.cs 프로젝트: vishal-h/btw-gtd
 public TrashStuffClicked(StuffId id)
 {
     Id = id;
 }
예제 #29
0
 public MutableStuff(StuffId stuffId, string description, string uiKey)
 {
     StuffId = stuffId;
     Description = description;
     UIKey = uiKey;
 }
예제 #30
0
 public ImmutableStuff(StuffId stuffId, string descriptionOfStuff, string uiKey)
 {
     StuffId = stuffId;
     Description = descriptionOfStuff;
     UIKey = uiKey;
 }
        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));
        }
예제 #32
0
 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()));
        }
예제 #34
0
        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));
            }
        }
예제 #35
0
 public TrashStuffClicked(StuffId id)
 {
     Id = id;
 }
예제 #36
0
 public StuffPutInInbox(TrustedSystemId id, StuffId stuffId, string stuffDescription, DateTime timeUtc)
 {
     Id = id;
     StuffId = stuffId;
     StuffDescription = stuffDescription;
     TimeUtc = timeUtc;
 }