public async System.Threading.Tasks.Task Handle(DueDateSetForTaskEvent message) { var t = ActiveDbContext.Tasks.Find(message.TaskId); t.DueDate = message.DueDate; await ActiveDbContext.SaveChangesAsync(); }
public void SetDueDate(DateTime dueDate) { if (this.DateOfCompletion.HasValue) { throw new InvalidOperationException("Can't set a due date for a completed task"); } if (this.DateOfCancellation.HasValue) { throw new InvalidOperationException("Can't set a due date for a cancelled task"); } if (dueDate < this.DateOfCreation) { throw new ArgumentException("The due date should be set later than the creation date.", nameof(dueDate)); } var e = new DueDateSetForTaskEvent() { DueDate = dueDate, TaskId = this.Id }; RaiseEvent(e); }
public void ApplyEvent(DueDateSetForTaskEvent @event) { this.DueDate = @event.DueDate; }