public void Update(DailyTaskId Id, Action <DailyTaskAggregate> execute) { while (true) { EventStream eventStream = _eventStore.LoadEventStream(Id); DailyTaskAggregate dailyTask = new DailyTaskAggregate(eventStream.Events, goalService); execute(dailyTask); try { _eventStore.AppendToStream(Id, eventStream.Version, dailyTask.Changes); return; } catch (OptimisticConcurrencyException ex) { foreach (var dailyTaskEvent in dailyTask.Changes) { foreach (var actualEvent in ex.ActualEvents) { if (ConflictsWith(dailyTaskEvent, actualEvent)) { var msg = string.Format("Conflict between {0} and {1}", dailyTaskEvent, actualEvent); throw new RealConcurrencyException(msg, ex); } } } _eventStore.AppendToStream(Id, ex.ActualVersion, dailyTask.Changes); } } }
public void SetTaskMissed(DailyTaskId id,DateTime taskDate) { if (_state.TaskCompletedOn.HasValue) throw new InvalidOperationException("This Task has already been completed."); if (_state.TaskMissed) throw new InvalidOperationException("This task has already been missed."); if (_state.TaskStartedAt.HasValue) throw new InvalidOperationException("This Task has already been started."); Apply(new DailyTaskMissed(id,taskDate)); }
public DailyTaskScheduled(DailyTaskId id, GoalId goalId, DateTime taskDate, string description, string user) { this.Id = id; this.GoalId = goalId; this.TaskDate = taskDate; this.Description = description; this.User = user; }
public void AssignDailyTask(DailyTaskId id,GoalId goalId,DateTime taskDate,string description, string user) { if (!goalService.HasGoalBeenCreated(goalId)) throw new InvalidOperationException("Goal Has not been created"); if (_state.Created) throw new InvalidOperationException("This Task has already been assigned."); if (!goalService.IsValidUser(goalId, user)) throw new InvalidOperationException("You are not not assign tasks to this goal."); Apply(new DailyTaskScheduled(id,goalId,taskDate,description, user)); }
public DailyTaskScheduled(DailyTaskId id, GoalId goalId, DateTime taskDate, string description, string user) { this.Id = id; this.GoalId = goalId; this.TaskDate = taskDate; this.Description = description; this.User = user; }
public void StartTask(DailyTaskId id, DateTime timeStarted) { if (_state.TaskStartedAt.HasValue) { throw new InvalidOperationException("This task has already been started"); } Apply(new DailyTaskStarted(id, timeStarted)); }
public void CompleteDailyTask(DailyTaskId id, DateTime completedTime) { if (_state.TaskCompletedOn.HasValue) { throw new InvalidOperationException("This Task has already been completed."); } if (!_state.TaskStartedAt.HasValue) { throw new InvalidOperationException("This Task has not been started."); } Apply(new DailyTaskCompleted(id, completedTime)); }
public void SetTaskMissed(DailyTaskId id, DateTime taskDate) { if (_state.TaskCompletedOn.HasValue) { throw new InvalidOperationException("This Task has already been completed."); } if (_state.TaskMissed) { throw new InvalidOperationException("This task has already been missed."); } if (_state.TaskStartedAt.HasValue) { throw new InvalidOperationException("This Task has already been started."); } Apply(new DailyTaskMissed(id, taskDate)); }
public void AssignDailyTask(DailyTaskId id, GoalId goalId, DateTime taskDate, string description, string user) { if (!goalService.HasGoalBeenCreated(goalId)) { throw new InvalidOperationException("Goal Has not been created"); } if (_state.Created) { throw new InvalidOperationException("This Task has already been assigned."); } if (!goalService.IsValidUser(goalId, user)) { throw new InvalidOperationException("You are not not assign tasks to this goal."); } Apply(new DailyTaskScheduled(id, goalId, taskDate, description, user)); }
public DailyTaskMissed(DailyTaskId id, DateTime taskDate) { this.Id = id; this.TaskDate = taskDate; }
public StartDailyTask(DailyTaskId id, DateTime startTime) { this.Id = id; this.StartTime = startTime; }
public SetDailyTaskToComplete(DailyTaskId id,DateTime completeTime) { this.Id = id; this.CompleteTime = completeTime; }
public DailyTaskStarted(DailyTaskId id, DateTime startTime) { this.Id = id; this.StartTime = startTime; }
public DailyTaskCompleted(DailyTaskId id, DateTime completeTime) { this.Id = id; this.CompleteTime = completeTime; }
public void CompleteDailyTask(DailyTaskId id,DateTime completedTime) { if (_state.TaskCompletedOn.HasValue) throw new InvalidOperationException("This Task has already been completed."); if (!_state.TaskStartedAt.HasValue) throw new InvalidOperationException("This Task has not been started."); Apply(new DailyTaskCompleted(id,completedTime)); }
public RecordDailyTaskMissed(DailyTaskId id, DateTime taskDate) { this.Id = id; this.TaskDate = taskDate; }
public StartDailyTask(DailyTaskId id, DateTime startTime) { this.Id = id; this.StartTime = startTime; }
public DailyTaskStarted(DailyTaskId id, DateTime startTime) { this.Id = id; this.StartTime = startTime; }
public SetDailyTaskToComplete(DailyTaskId id, DateTime completeTime) { this.Id = id; this.CompleteTime = completeTime; }
public DailyTaskCompleted(DailyTaskId id, DateTime completeTime) { this.Id = id; this.CompleteTime = completeTime; }
public void StartTask(DailyTaskId id,DateTime timeStarted) { if (_state.TaskStartedAt.HasValue) throw new InvalidOperationException("This task has already been started"); Apply(new DailyTaskStarted(id, timeStarted)); }