Beispiel #1
0
        public Sprint EndSprint(int projectId, Sprint sprint)
        {
            if (sprint.State != SprintState.ACTIVE)
            {
                throw new CheckedException($"Sprint has not been started.");
            }
            var date = DateTime.Today;

            _projectDAO.EndSprint(sprint.Id, date);
            foreach (var userStory in sprint.UserStories)
            {
                bool isFinished = true;
                foreach (var task in userStory.Tasks)
                {
                    if (!task.IsApproved)
                    {
                        isFinished = false;
                        _projectDAO.ResetAssignedMember(task.Id);
                    }
                }
                _projectDAO.UpdateUserStoryState(userStory.Id, isFinished? UserStoryState.RESOLVED: UserStoryState.BACKLOG);
            }

            var newSprint = new Sprint()
            {
                Order = sprint.Order + 1,
                State = SprintState.QUEUING,
            };

            _projectDAO.AddSprint(projectId, newSprint);
            var project = _projectDAO.GetProjectById(projectId);

            return(project.Sprints.OrderByDescending(s => s.Order).First());
        }