Skip to content

Commit

Permalink
Fixed create project action and added data source handler to project …
Browse files Browse the repository at this point in the history
…identifier
  • Loading branch information
vitalii-bezuhlyi committed Jun 26, 2024
1 parent f2fb975 commit 802fc91
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Apps.XtrfCustomerPortal/Actions/ProjectActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public async Task<ProjectResponse> CreateProject([ActionParameter] CreateProject
catToolType = request.CatToolType ?? "TRADOS"
};

var projectDto = await Client.ExecuteRequestAsync<ProjectDto>("/projects", Method.Post, obj);
var projectDto = await Client.ExecuteRequestAsync<ProjectDto>("/v2/projects", Method.Post, obj);
return new ProjectResponse(projectDto);
}

Expand Down
24 changes: 24 additions & 0 deletions Apps.XtrfCustomerPortal/DataSources/ProjectDataSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Apps.XtrfCustomerPortal.Actions;
using Apps.XtrfCustomerPortal.Invocables;
using Apps.XtrfCustomerPortal.Models.Requests;
using Blackbird.Applications.Sdk.Common.Dynamic;
using Blackbird.Applications.Sdk.Common.Invocation;

namespace Apps.XtrfCustomerPortal.DataSources;

public class ProjectDataSource(InvocationContext invocationContext)
: AppInvocable(invocationContext), IAsyncDataSourceHandler
{
public async Task<Dictionary<string, string>> GetDataAsync(DataSourceContext context, CancellationToken cancellationToken)
{
var projectActions = new ProjectActions(invocationContext, null!);

var quotes = await projectActions.SearchProjects(new SearchProjectsRequest()
{
Search = context.SearchString ?? string.Empty
});

return quotes.Projects
.ToDictionary(x => x.ProjectId, x => x.ProjectName);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using Apps.XtrfCustomerPortal.DataSources;
using Blackbird.Applications.Sdk.Common;
using Blackbird.Applications.Sdk.Common.Dynamic;

namespace Apps.XtrfCustomerPortal.Models.Identifiers;

public class ProjectIdentifier
{
[Display("Project ID")]
[Display("Project ID"), DataSource((typeof(ProjectDataSource)))]
public string ProjectId { get; set; }
}

0 comments on commit 802fc91

Please sign in to comment.