public CommittedBacklogItem(TenantId tenantId, SprintId sprintId, BacklogItemId backlogItemId, int ordering = 0)
 {
     this.TenantId = tenantId;
     this.SprintId = sprintId;
     this.BacklogItemId = backlogItemId;
     this.Ordering = ordering;
 }
        public BacklogItemCommitted(TenantId tenantId, BacklogItemId backlogItemId, SprintId sprintId)
        {
            this.TenantId = tenantId;
            this.BacklogItemId = backlogItemId;
            this.SprintId = sprintId;

            this.EventVersion = 1;
            this.OccurredOn = DateTime.Now;
        }
        public ProductSprintScheduled(TenantId tenantId, ProductId productId, SprintId sprintId, string name,
            string goals, DateTime starts, DateTime ends)
        {
            this.TenantId = tenantId;
            this.ProductId = productId;
            this.SprintId = sprintId;
            this.Name = name;
            this.Goals = goals;
            this.Starts = starts;
            this.Ends = ends;

            this.EventVersion = 1;
            this.OccurredOn = DateTime.Now;
        }
        public Sprint(TenantId tenantId, ProductId productId, SprintId sprintId, string name, string goals,
            DateTime begins, DateTime ends)
        {
            if(ends.Ticks<begins.Ticks) {
                throw new InvalidOperationException("Sprint must not end before it begins.");
            }
            this.TenantId = tenantId;
            this.ProductId = productId;
            this.SprintId = sprintId;
            this.Name = name;
            this.Goals = goals;
            this.Begins = begins;
            this.Ends = ends;

            _backlogItems = new HashSet<CommittedBacklogItem>();
        }
        public Sprint ScheduleSprint(SprintId newSprintId, string name, string goals, DateTime begins, DateTime ends)
        {
            Sprint sprint = new Sprint(this.TenantId, this.ProductId, newSprintId, name, goals, begins, ends);
            DomainEventPublisher.Instance.Publish(new ProductSprintScheduled(sprint.TenantId, sprint.ProductId,
                sprint.SprintId, sprint.Name, sprint.Goals, sprint.Begins, sprint.Ends));

            return sprint;
        }