Beispiel #1
0
        public ViewBacklogResponse Execute(ViewBacklogRequest request)
        {
            request.ThrowExceptionIfInvalid();

            var project = _projectRepository.Read(request.ProjectId);
            var team    = _teamRepository.Read(project.TeamId);
            var backlog = _projectRepository.ReadProductBacklog(project.Id);

            var backlogTasks = backlog.Select(x =>
            {
                var task       = _workTaskRepository.Read(x.WorkTaskId);
                var parentTask = task.ParentTask.IsBlankIdentity() ? null : _workTaskRepository.Read(task.ParentTask);

                return(new ViewBacklogResponse.Task
                {
                    Id = task.Id,
                    Name = task.Name,
                    Type = task.Type,
                    Status = x.Status,
                    StoryPoints = task.StoryPoints,
                    ParentTask = parentTask?.ToInfo(),
                });
            });

            var activeBacklogTasks = backlogTasks.Where(x => request.Include(x.Status));

            return(new ViewBacklogResponse
            {
                ProjectId = request.ProjectId,
                Tasks = activeBacklogTasks,
                CanManageBacklog = team.Members.Any(x => x.Id == Identity.FromString(request.UserId))
            });
        }
        public ConfirmationResponse Execute(AuthorizedIdRequest request)
        {
            request.ThrowExceptionIfInvalid();

            var workTask = _workTaskRepository.Read(request.Id);
            var backlog  = _projectRepository.ReadProductBacklog(workTask.ProjectId);

            var taskInBacklog = backlog.FirstOrDefault(x => x.WorkTaskId == workTask.Id);

            if (taskInBacklog != null)
            {
                foreach (var s in workTask.ChildTasks)
                {
                    if (!backlog.IsTaskInBacklog(s))
                    {
                        backlog.AddTaskToBacklog(new ProductBacklog.WorkTaskWithStatus(s, taskInBacklog.Status));
                    }
                }

                backlog.RemoveTaskFromBacklog(workTask.Id);
            }

            _projectRepository.UpdateProductBacklog(backlog);
            _workTaskRepository.Delete(workTask.Id);

            return(new ConfirmationResponse($"WorkTask {workTask.Name} successfully deleted.")
            {
                Id = workTask.Id,
            });
        }
Beispiel #3
0
        public SprintReportResponse Execute(AuthorizedIdRequest request)
        {
            request.ThrowExceptionIfInvalid();

            var sprint  = _sprintRepository.Read(request.Id);
            var backlog = _sprintRepository.ReadSprintBacklog(sprint.Id);
            var records = _sprintRepository.ReadHistoryRecords(sprint.Id);

            var groupByDate = records.GroupBy(x => x.Date).Select(x => new SprintReportResponse.Record
            {
                Date            = x.Key,
                DoneTasks       = x.Average(y => y.DoneTasks),
                ToDoTasks       = x.Average(y => y.ToDoTasks),
                InProgressTasks = x.Average(y => y.InProgressTasks),
            }).OrderBy(x => x.Date).ToList();

            var stories = backlog.Stories.Select(x =>
            {
                var story = _workTaskRepository.Read(x);

                return(new SprintReportResponse.Story
                {
                    Id = story.Id,
                    Name = story.Name,
                    StoryPoints = story.StoryPoints,
                    Completed = backlog.CompletedStories.Contains(x),
                    CompletedTasks = backlog.Tasks.Count(y => y.ParentTaskId == x && y.Status == SprintBacklog.WorkTaskStatus.Done),
                    TotalTasks = backlog.Tasks.Count(y => y.ParentTaskId == x),
                });
            });

            if (groupByDate.Last().Date.Date != sprint.TimeSpan.Item2.Date)
            {
                var diff = sprint.TimeSpan.Item2.Date.Subtract(groupByDate.Last().Date.Date).Days;
                for (var i = 1; i <= diff; ++i)
                {
                    var item = groupByDate.Last();
                    groupByDate.Add(new SprintReportResponse.Record
                    {
                        Date            = item.Date.AddDays(i),
                        DoneTasks       = item.DoneTasks,
                        ToDoTasks       = item.ToDoTasks,
                        InProgressTasks = item.InProgressTasks,
                    });
                }
            }

            return(new SprintReportResponse
            {
                Sprint = sprint.ToInfo(),
                Goal = sprint.Goal,
                ProjectId = sprint.ProjectId,
                TimeSpan = sprint.TimeSpan,
                Stories = stories.ToArray(),
                Records = groupByDate.ToArray(),
            });
        }
Beispiel #4
0
        public ProjectReportResponse Execute(AuthorizedIdRequest request)
        {
            request.ThrowExceptionIfInvalid();

            var project = _projectRepository.Read(request.Id);
            var records = _projectRepository.ReadHistoryRecords(project.Id);
            var sprints = _sprintRepository.ReadSprints(project.Id, SprintStatus.Done);

            var recordsByDate = records.GroupBy(x => x.Date).Select(x => new ProjectReportResponse.Record
            {
                Date          = x.Key,
                DoneTasks     = x.Average(y => y.DoneTasks),
                ToDoTasks     = x.Average(y => y.ToDoTasks),
                InSprintTasks = x.Average(y => y.InSprintTasks),
                ReadyTasks    = x.Average(y => y.ReadyTasks),
            });

            var sprintReports = sprints.Select(x =>
            {
                var sprintBacklog = _sprintRepository.ReadSprintBacklog(x.Id);

                return(new ProjectReportResponse.Sprint
                {
                    Id = x.Id,
                    Name = x.Name,
                    EndDate = x.TimeSpan.Item2,
                    PlannedStories = sprintBacklog.Stories.Count,
                    PlannedValue = sprintBacklog.Stories.Sum(y => _workTaskRepository.Read(y).StoryPoints ?? 0),
                    CompletedStories = sprintBacklog.CompletedStories.Count,
                    CompletedValue = sprintBacklog.CompletedStories.Sum(y => _workTaskRepository.Read(y).StoryPoints ?? 0),
                });
            });

            return(new ProjectReportResponse
            {
                Project = project.ToInfo(),
                Records = recordsByDate.ToArray(),
                Sprints = sprintReports.ToArray(),
            });
        }
Beispiel #5
0
        public ConfirmationResponse Execute(DeleteCommentRequest request)
        {
            request.ThrowExceptionIfInvalid();

            var task = _workTaskRepository.Read(request.WorkTaskId);

            _workTaskRepository.DeleteComment(task.Id, request.CommentId);

            return(new ConfirmationResponse("Comment deleted successfully.")
            {
                Id = task.Id,
            });
        }
        public ConfirmationResponse Execute(EditCommentRequest request)
        {
            request.ThrowExceptionIfInvalid();

            var task    = _workTaskRepository.Read(request.WorkTaskId);
            var comment = _workTaskRepository.ReadComment(task.Id, request.CommentId);

            comment.Content = request.Content;
            _workTaskRepository.UpdateComment(comment);

            return(new ConfirmationResponse("Comment updated successfully.")
            {
                Id = task.Id,
            });
        }
        public ConfirmationResponse Execute(EditWorkTaskRequest request)
        {
            request.ThrowExceptionIfInvalid();

            var entity  = _workTaskRepository.Read(request.Id);
            var backlog = _projectRepository.ReadProductBacklog(entity.ProjectId);

            var oldChildren = entity.ChildTasks;

            UpdateWorkTask(entity, request);

            var hasBacklogChanged = false;

            if (entity.Type == WorkTaskType.UserStory)
            {
                var removedChildren = oldChildren.Except(entity.ChildTasks).ToArray();
                foreach (var task in entity.ChildTasks)
                {
                    hasBacklogChanged |= backlog.RemoveTaskFromBacklog(task);
                }

                foreach (var child in removedChildren)
                {
                    backlog.AddTaskToBacklog(new ProductBacklog.WorkTaskWithStatus(child, ProductBacklog.WorkTaskStatus.ToDo));
                }

                hasBacklogChanged |= removedChildren.Any();
            }
            else if (entity.Type != WorkTaskType.Epic && entity.ParentTask.IsBlankIdentity())
            {
                backlog.AddTaskToBacklog(new ProductBacklog.WorkTaskWithStatus(entity.Id, ProductBacklog.WorkTaskStatus.ToDo));
                hasBacklogChanged = true;
            }

            _workTaskRepository.Update(entity);
            if (hasBacklogChanged)
            {
                _projectRepository.UpdateProductBacklog(backlog);
            }

            return(new ConfirmationResponse("Work task updated successfully.")
            {
                Id = entity.Id,
            });
        }
Beispiel #8
0
        public ConfirmationResponse Execute(AddCommentRequest request)
        {
            request.ThrowExceptionIfInvalid();

            var task = _workTaskRepository.Read(request.WorkTaskId);

            var comment = new Core.Entities.WorkTask.Comment(
                _workTaskRepository.GenerateNewIdentity(),
                request.AuthorId,
                task.Id,
                request.Content);

            _workTaskRepository.AddComment(comment);

            return(new ConfirmationResponse("Comment added successfully.")
            {
                Id = task.Id,
            });
        }
        public ViewSprintResponse Execute(AuthorizedIdRequest request)
        {
            request.ThrowExceptionIfInvalid();

            var sprint  = _sprintRepository.Read(request.Id);
            var backlog = _sprintRepository.ReadSprintBacklog(sprint.Id);

            if (sprint.Status == SprintStatus.Planned)
            {
                var tasks = new List <SprintBacklog.WorkTaskWithStatus>();
                foreach (var storyId in backlog.Stories)
                {
                    var story = _workTaskRepository.Read(storyId);
                    tasks.AddRange(
                        story.ChildTasks
                        .Select(task => new SprintBacklog.WorkTaskWithStatus(task, storyId, SprintBacklog.WorkTaskStatus.ToDo)));
                }

                backlog.Tasks = tasks;
            }

            var responseStories = backlog.Stories.Select(x => new ViewSprintResponse.Story
            {
                Id        = x,
                Completed = backlog.CompletedStories.Contains(x),
                Tasks     = backlog.Tasks
                            .Where(y => y.ParentTaskId == x)
                            .Select(y => new Tuple <Identity, SprintBacklog.WorkTaskStatus>(y.WorkTaskId, y.Status)),
            });

            return(new ViewSprintResponse
            {
                Id = sprint.Id,
                Goal = sprint.Goal,
                Name = sprint.Name,
                ProjectId = sprint.ProjectId,
                TimeSpan = sprint.TimeSpan,
                Stories = responseStories,
                CanDelete = sprint.Status == SprintStatus.Planned,
                Documents = sprint.Documents,
                IsReportAvailable = sprint.Status != SprintStatus.Planned,
            });
        }
        public ConfirmationResponse Execute(StartSprintRequest request)
        {
            request.ThrowExceptionIfInvalid();

            var sprint = _sprintRepository.Read(request.Id);
            var currentSprintOfProject = _sprintRepository.ReadCurrentSprint(sprint.ProjectId);

            if (currentSprintOfProject != null)
            {
                request.Errors.Add("", "Project already has a active sprint.");
                throw new InvalidRequestException {
                          Errors = request.Errors
                };
            }

            sprint.Status   = SprintStatus.InProgress;
            sprint.TimeSpan = new Tuple <DateTime, DateTime>(request.CurrentTime, sprint.TimeSpan.Item2);

            var backlog = _sprintRepository.ReadSprintBacklog(sprint.Id);
            var tasks   = new List <SprintBacklog.WorkTaskWithStatus>();

            foreach (var storyId in backlog.Stories)
            {
                var story = _workTaskRepository.Read(storyId);
                tasks.AddRange(
                    story.ChildTasks
                    .Select(task => new SprintBacklog.WorkTaskWithStatus(task, storyId, SprintBacklog.WorkTaskStatus.ToDo)));
            }

            backlog.Tasks = tasks;

            _sprintRepository.Update(sprint);
            _sprintRepository.UpdateCurrentTasks(backlog);

            return(new ConfirmationResponse("Sprint started successfully.")
            {
                Id = sprint.ProjectId,
            });
        }
Beispiel #11
0
        public ViewWorkTaskResponse Execute(AuthorizedIdRequest request)
        {
            request.ThrowExceptionIfInvalid();

            var entity = _workTaskRepository.Read(request.Id);

            return(new ViewWorkTaskResponse
            {
                Id = entity.Id,
                Name = entity.Name,
                Description = entity.Description,
                ProjectId = entity.ProjectId,
                ParentTask = entity.ParentTask,
                Type = entity.Type,
                ChildTasks = entity.ChildTasks,
                StoryPoints = entity.StoryPoints,
                Steps = entity.Steps,
                Comments = entity.Comments,
                CanEdit = CanWorkTaskBeEdited(entity),
                CanEditParent = entity.ParentTask.IsBlankIdentity() || CanWorkTaskBeEdited(_workTaskRepository.Read(entity.ParentTask)),
                Documents = entity.Documents,
            });
        }