public void MarkComplete() { if (IsComplete) { return; } IsComplete = true; HoursRemaining = 0; AggregateEvents.Raise(new TaskCompletedEvent(this)); }
private void NewAggregateEvent(AggregateEvent aggEvent) { try { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { AggregateEvents.Add(aggEvent); })); } catch (System.Threading.ThreadInterruptedException intExc) { System.Diagnostics.Trace.Write(intExc.Message); } }
public void DeleteTask(Guid id) { var taskToDelete = _tasks.SingleOrDefault(t => t.Id == id); if (taskToDelete == null) { return; } _tasks.Remove(taskToDelete); // why raise this event here? // TODO: Replace with Domain Event? AggregateEvents.Raise(new TaskDeletedEvent(taskToDelete)); Log($"{taskToDelete.Name} deleted."); }
public void HandleOwnTaskHoursUpdatedEventOnly() { AggregateEvents.ClearCallbacks(); var project = new Project(); string taskName = Guid.NewGuid().ToString(); project.AddTask(taskName, 1); // project 2 has no tasks assigned to it. var project2 = new Project(); project.Tasks.First().UpdateHoursRemaining(2); Assert.Contains(taskName, project.ToString()); Assert.DoesNotContain(taskName, project2.ToString()); }
public void Can_from_Retrieve_DomainEvents_list() { var client = new RedisClient(Config.MasterHost); var users = client.As <AggregateEvents>(); var userId = Guid.NewGuid(); var eventsForUser = new AggregateEvents { Id = userId, Events = new List <DomainEvent>() }; eventsForUser.Events.Add(new UserPromotedEvent { UserId = userId }); users.Store(eventsForUser); var all = users.GetAll(); }
public void UpdateHoursRemaining(int hours) { if (hours < 0) { return; } int currentHoursRemaining = HoursRemaining; try { HoursRemaining = hours; if (HoursRemaining == 0) { MarkComplete(); return; } IsComplete = false; AggregateEvents.Raise(new TaskHoursUpdatedEvent(this)); } catch (Exception) { HoursRemaining = currentHoursRemaining; } }
public Project() { AggregateEvents.Register <TaskCompletedEvent>(HandleTaskCompleted); AggregateEvents.Register <TaskHoursUpdatedEvent>(HandleTaskHoursUpdated); }
private void ExecuteClearAggregateCommand() { AggregateEvents.Clear(); }