public SuccessResponse PostSprint(CreateSprintRequest sprint) { var result = _createValidator.Validate(sprint, ruleSet: "Required"); if (!result.IsValid) { foreach (var failure in result.Errors) { return(new SuccessResponse { Message = failure.PropertyName + " failed validation." + failure.ErrorMessage }); } } var newSprint = _mapper.Map <Sprint>(sprint); var SprintId = _sprintLogic.CreateSprint(newSprint); return(new SuccessResponse { Id = SprintId, Message = "Sprint Created Successfully" }); }
public ConfirmationResponse Execute(CreateSprintRequest request) { request.ThrowExceptionIfInvalid(); var entity = ToDomainEntity(request); var projectBacklog = _projectRepository.ReadProductBacklog(request.ProjectId); foreach (var story in request.Stories) { projectBacklog.UpdateTask(new ProductBacklog.WorkTaskWithStatus(story, ProductBacklog.WorkTaskStatus.InSprint)); } var result = _sprintRepository.Create(entity); var backlog = ToDomainEntity(result, request.Stories); _sprintRepository.UpdatePlannedTasks(backlog); _projectRepository.UpdateProductBacklog(projectBacklog); return(new ConfirmationResponse("Sprint created successfully.") { Id = result, }); }
private Core.Entities.Sprint ToDomainEntity(CreateSprintRequest request) => new Core.Entities.Sprint(_sprintRepository.GenerateNewIdentity(), request.ProjectId, request.Name, request.TimeSpan, request.Goal, SprintStatus.Planned, request.Documents);