Skip to content

Commit

Permalink
fixes #67
Browse files Browse the repository at this point in the history
  • Loading branch information
markusheiliger committed Mar 27, 2020
1 parent 872e3fe commit ab11d68
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/TeamCloud.API/Services/Orchestrator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,34 @@ private void SetResultLinks(ICommandResult commandResult, Guid? projectId)
{
commandResult.Links.Add("location", new Uri(baseUrl, "api/config").ToString());
}
else if (commandResult is ICommandResult<User> commandResultUserWithProject && projectId.HasValue)
else if (IsDeleteCommandResult(commandResult))
{
commandResult.Links.Add("location", new Uri(baseUrl, $"api/projects/{projectId}/users/{commandResultUserWithProject.Result?.Id}").ToString());
return;
}
else if (commandResult is ICommandResult<User> commandResultUserWithoutProject)
else if (commandResult is ICommandResult<User> userCommandResult)
{
commandResult.Links.Add("location", new Uri(baseUrl, $"api/users/{commandResultUserWithoutProject.Result?.Id}").ToString());
if (userCommandResult.Result is null)
return;

if (projectId.HasValue)
{
commandResult.Links.Add("location", new Uri(baseUrl, $"api/projects/{projectId}/users/{userCommandResult.Result.Id}").ToString());
}
else
{
commandResult.Links.Add("location", new Uri(baseUrl, $"api/users/{userCommandResult.Result.Id}").ToString());
}
}
else if (projectId.HasValue)
{
commandResult.Links.Add("location", new Uri(baseUrl, "api/projects/{projectId}").ToString());
}

static bool IsDeleteCommandResult(ICommandResult result)
=> result is OrchestratorProjectDeleteCommandResult
|| result is OrchestratorProjectUserDeleteCommandResult
|| result is OrchestratorProviderDeleteCommandResult
|| result is OrchestratorTeamCloudUserDeleteCommandResult;
}

public async Task<ICommandResult> QueryAsync(Guid commandId, Guid? projectId)
Expand Down

0 comments on commit ab11d68

Please sign in to comment.