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;
        }
 public void DefineTask(TeamMember volunteer, string name, string description, int hoursRemaining)
 {
     Task task = new Task(this.TenantId, this.BacklogItemId, new TaskId(), volunteer, name, description,
         hoursRemaining, TaskStatus.NotStarted);
     this._tasks.Add(task);
     DomainEventPublisher.Instance.Publish(new TaskDefined(this.TenantId, this.BacklogItemId, task.TaskId,
         volunteer.TeamMemberId.Id, name, description));
 }
 public void AssignTaskVolunteer(TaskId taskId, TeamMember volunteer)
 {
     Task task = this.LoadTask(taskId);
     task.AssignVolunteer(volunteer);
 }
 public void EnableTeamMember(EnableTeamMemberCommand command)
 {
     TenantId tenantId = new TenantId(command.TenantId);
     ApplicationServiceLifeCycle.Begin();
     try {
         TeamMember teamMember = this._teamMemberRepository.Get(tenantId, command.UserName);
         if (teamMember != null) {
             teamMember.Enable(command.OccurredOn);
         }
         else {
             teamMember = new TeamMember(tenantId, command.UserName, command.FirstName, command.LastName,
                 command.EmailAdddress, command.OccurredOn);
             this._teamMemberRepository.Save(teamMember);
         }
         ApplicationServiceLifeCycle.Success();
     }
     catch (Exception ex) {
         ApplicationServiceLifeCycle.Fail(ex);
     }
 }
 public void RemoveTeamMember(TeamMember teamMember)
 {
     AssertValidTeamMember(teamMember);
     TeamMember existingTeamMember = GetTeamMemberByUserName(teamMember.UserName);
     if(existingTeamMember!=null) {
         this._teamMembers.Remove(existingTeamMember);
     }
 }
 public bool IsTeamMember(TeamMember teamMember)
 {
     AssertValidTeamMember(teamMember);
     return GetTeamMemberByUserName(teamMember.UserName) != null;
 }
 public void AssignTeamMember(TeamMember teamMember)
 {
     AssertValidTeamMember(teamMember);
     this._teamMembers.Add(teamMember);
 }
 private void AssertValidTeamMember(TeamMember teamMember)
 {
     AssertionConcern.NotNull(teamMember, "A team member must be provided.");
     AssertionConcern.Equals(this.TenantId, teamMember.TenantId, "Team member must be of the same tenant.");
 }
 internal void AssignVolunteer(TeamMember teamMember)
 {
     AssertionConcern.NotNull(teamMember, "A valunteer must be provided.");
     this.Volunteer = teamMember.TeamMemberId;
     DomainEventPublisher.Instance.Publish(new TaskVolunteerAssigned(this.TenantId, this.BacklogItemId,
         this.TaskId, teamMember.TeamMemberId.Id));
 }