public TaskRenamed(TenantId tenantId, BacklogItemId backlogItemId, TaskId taskId, string name)
 {
     this.TenantId = tenantId;
     this.BacklogItemId = backlogItemId;
     this.TaskId = taskId;
     this.Name = name;
 }
        public TaskDescribed(TenantId tenantId, BacklogItemId backlogItemId, TaskId taskId, string description)
        {
            this.TenantId = tenantId;
            this.BacklogItemId = backlogItemId;
            this.TaskId = taskId;
            this.Description = description;

            this.EventVersion = 1;
            this.OccurredOn = DateTime.Now;
        }
        public TaskStatusChanged(TenantId tenantId, BacklogItemId backlogItemId, TaskId taskId, TaskStatus status)
        {
            this.TenantId = tenantId;
            this.BacklogItemId = backlogItemId;
            this.TaskId = taskId;
            this.Status = status;

            this.EventVersion = 1;
            this.OccurredOn = DateTime.Now;
        }
 public TaskDefined(TenantId tenantId, BacklogItemId backlogItemId, TaskId taskId, string volunteerMemberId,
     string name, string description)
 {
     this.TenantId = tenantId;
     this.BacklogItemId = backlogItemId;
     this.TaskId = taskId;
     this.VolunteerMemberId = volunteerMemberId;
     this.Name = name;
     this.Description = description;
 }
        public EstimationLogEntry(TenantId tenantId, TaskId taskId, DateTime date, int hoursRemaining)
        {
            AssertionConcern.NotNull(tenantId, "The tenant id must be provided.");
            AssertionConcern.NotNull(taskId, "The task id must be provided.");

            this.TenantId = tenantId;
            this.TaskId = taskId;
            this.Date = date;
            this.HoursRemaining = hoursRemaining;
        }
        public TaskHoursRemainingEstimated(TenantId tenantId, BacklogItemId backlogItemId, TaskId taskId,
            int hoursRemaining)
        {
            this.TenantId = tenantId;
            this.BacklogItemId = backlogItemId;
            this.TaskId = taskId;
            this.HoursRemaining = hoursRemaining;

            this.EventVersion = 1;
            this.OccurredOn = DateTime.Now;
        }
        public TaskVolunteerAssigned(TenantId tenantId, BacklogItemId backlogItemId, TaskId taskId,
            string volunteerMemberId)
        {
            this.TenantId = tenantId;
            this.BacklogItemId = backlogItemId;
            this.TaskId = taskId;
            this.VolunteerMemberId = volunteerMemberId;

            this.EventVersion = 1;
            this.OccurredOn = DateTime.Now;
        }
        public Task(TenantId tenantId, BacklogItemId backlogItemId, TaskId taskId, TeamMember teamMember, string name,
            string description, int hoursRemaining, TaskStatus status)
        {
            AssertionConcern.NotEmpty(name, "Name is required.");
            AssertionConcern.Length(name, 100, "Name must be 100 characters or less");
            AssertionConcern.NotEmpty(description, "Description is required.");
            AssertionConcern.Length(description, 65000, "Description must be 65000 characters or less.");
            AssertionConcern.NotNull(teamMember, "The team member must be provided");
            AssertionConcern.Equals(tenantId, teamMember.TeamMemberId.TenantId,
                "The volunteer must be of the same tenant.");

            this.TenantId = tenantId;
            this.BacklogItemId = backlogItemId;
            this.TaskId = taskId;
            this.Volunteer = teamMember.TeamMemberId;
            this.Name = name;
            this.Description = description;
            this.HoursRemaining = hoursRemaining;
            this.Status = status;
        }
 private Task LoadTask(TaskId taskId)
 {
     Task task = this.GetTask(taskId);
     if(task==null) {
         throw new InvalidOperationException("Task does not exist.");
     }
     return task;
 }
 public void RenameTask(TaskId taskId, string name)
 {
     Task task = this.LoadTask(taskId);
     task.Rename(name);
 }
        public void RemoveTask(TaskId taskId)
        {
            Task task = this.LoadTask(taskId);

            if(!this._tasks.Remove(task)) {
                throw new InvalidOperationException("Task was not removed.");
            }

            DomainEventPublisher.Instance.Publish(new TaskRemoved(this.TenantId, this.BacklogItemId));
        }
 public Task GetTask(TaskId taskId)
 {
     return this._tasks.FirstOrDefault(x => x.TaskId.Equals(taskId));
 }
        public void EstimateTaskHoursRemaining(TaskId taskId, int hoursRemaining)
        {
            Task task = this.LoadTask(taskId);
            task.EstimateHoursRemaining(hoursRemaining);

            BacklogItemStatus? changedStatus = default (BacklogItemStatus?);

            if(hoursRemaining==0) {
                if(!this.AnyTaskHoursRemaining) {
                    changedStatus = BacklogItemStatus.Done;
                }
            }
            else if(this.IsDone) {
                if(this.IsCommittedToSprint) {
                    changedStatus = BacklogItemStatus.Committed;
                }
                else if(this.IsScheduledForRelease) {
                    changedStatus = BacklogItemStatus.Scheduled;
                }
                else {
                    changedStatus = BacklogItemStatus.Planned;
                }
            }

            if(changedStatus != null) {
                this.Status = changedStatus.Value;
                DomainEventPublisher.Instance.Publish(new BacklogItemStatusChanged(this.TenantId, this.BacklogItemId,
                    changedStatus.Value));
            }
        }
 public void DescribeTask(TaskId taskId, string description)
 {
     Task task = this.LoadTask(taskId);
     task.DescribeAs(description);
 }
 public void ChangeTaskStatus(TaskId taskId, TaskStatus status)
 {
     Task task = this.LoadTask(taskId);
     task.ChangeStatus(status);
 }
 public void AssignTaskVolunteer(TaskId taskId, TeamMember volunteer)
 {
     Task task = this.LoadTask(taskId);
     task.AssignVolunteer(volunteer);
 }