private async Task <BacklogItemReference> CreateBacklogItem() { var dto = new BugAddUpdRequest { Title = "Test_" + GetRandomString() }; var addedRef = await _commandService.Create(dto); if (!addedRef.IsSuccess) { throw new Exception("Failed to create a backlog item"); } await SaveChanges(); return(addedRef.Value); }
public async Task Run(CancellationToken cancellationToken) { var userReferences = await _seededUser.GetGeneratedUsers(); await _dbSession.SaveChangesAsync(cancellationToken); foreach (var repo in _gitHubSettings.Repos) { await foreach (var issues in _gitHubService.GetIssues(repo, _gitHubSettings.MaxImportedIssues, cancellationToken).WithCancellation(cancellationToken)) { foreach (var issue in issues) { BacklogItemAddUpdRequestBase dto; if (issue.Labels.Any(l => l.Name == "bug")) { dto = ConvertToBacklogItem <BugAddUpdRequest>(issue, userReferences, d => { var rnd = new Random(); d.StepsToReproduce = issue.Body; d.Severity = (BugSeverity)rnd.Next(Enum.GetNames(typeof(BugSeverity)).Length); d.Priority = (BugPriority)rnd.Next(Enum.GetNames(typeof(BugPriority)).Length); } ); } else { dto = ConvertToBacklogItem <UserStoryAddUpdRequest>(issue, userReferences, d => d.AcceptanceCriteria = issue.Body); } var importResult = await _backlogItemService.Create(dto); if (!importResult.IsSuccess) { throw new Exception($"Failed to import issue #{issue.Number}"); } if (issue.CommentsCount > 0) { foreach (var commentDto in issue.Comments.Select(comment => ConvertToComment(comment, userReferences))) { await _backlogCommentService.Create(importResult.Value.Id !, commentDto); } } } await _dbSession.SaveChangesAsync(cancellationToken); } } }
private async Task <BacklogItemReference> CreateSampleBug() { var dto = new BugAddUpdRequest { Title = "Test Bug", Severity = BugSeverity.Critical, Priority = BugPriority.P1 }; var ticketAddedRef = await _commandService.Create(dto); if (!ticketAddedRef.IsSuccess) { throw new Exception("Failed to create a backlog item"); } await SaveChanges(); return(ticketAddedRef.Value); }
private async Task <string> CreateBacklogItem <T>(string customFieldId, T customFieldValue) where T : notnull { var dto = new BugAddUpdRequest { Title = "Test_" + GetRandomString(), ChangedCustomFields = new List <BacklogCustomFieldAction> { new() { CustomFieldId = customFieldId, ObjValue = customFieldValue, ActionType = ListActionType.Add } } }; var addedRef = await _commandService.Create(dto); if (!addedRef.IsSuccess) { throw new Exception("Failed to create a backlog item"); } await SaveChanges(); return(addedRef.Value.Id !); }
private async Task <string> CreateBacklogItem <T>(string customFieldId, T customFieldValue) { var dto = new BugAddUpdRequest { Title = "Test_" + GetRandomString(), CustomFields = new Dictionary <string, object?> { { customFieldId, customFieldValue } } }; var addedRef = await _commandService.Create(dto); if (!addedRef.IsSuccess) { throw new Exception("Failed to create a backlog item"); } await SaveChanges(); return(addedRef.Value.Id !); }
private async Task <BacklogItemReference> CreateSampleBug(params string[] customFieldId) { var dto = new BugAddUpdRequest { Title = "Test Bug", Severity = BugSeverity.Critical, Priority = BugPriority.P1, ChangedCustomFields = customFieldId.Select(id => new BacklogCustomFieldAction { CustomFieldId = id, ObjValue = "Test", ActionType = ListActionType.Add }).ToList() }; var ticketAddedRef = await _commandTicketService.Create(dto); if (!ticketAddedRef.IsSuccess) { throw new Exception("Failed to create a backlog item"); } await SaveChanges(); return(ticketAddedRef.Value); }
public Task <ActionResult <BacklogItemReference> > Create([FromServices] IBacklogItemCommandService service, UserStoryAddUpdRequest dto) => service.Create(dto).ToActionResultOfT();