-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStuctureController.cs
More file actions
61 lines (51 loc) · 2.55 KB
/
StuctureController.cs
File metadata and controls
61 lines (51 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using Microsoft.AspNetCore.Mvc;
using PrismaApi.Application.Interfaces.Services;
using PrismaApi.Domain.Dtos;
using Scampi.Domain.Extensions;
using System.Net;
using PrismaApi.Api.Extensions;
namespace PrismaApi.Api.Controllers;
[ApiController]
public class StuctureController : PrismaBaseController
{
private readonly IFastApiService _fastApiService;
private readonly IUserService _userService;
public StuctureController(IFastApiService fastApiService, IUserService userService)
{
_fastApiService = fastApiService;
_userService = userService;
}
[HttpGet("structure/{projectId:guid}/decision_tree/v2")]
public async Task<ActionResult<ApiResponseDto>> GetDecisionTreeAsync([FromRoute] Guid projectId)
{
UserOutgoingDto user = HttpContext.GetLoadedUser();
var fastApiResponse = await _fastApiService.SendInfluenceDiagramToFastApiAsync(projectId, $"/structure/{projectId}/decision_tree/v2", user);
if (fastApiResponse.StatusCode == HttpStatusCode.OK)
{
return Ok(!string.IsNullOrEmpty(fastApiResponse.Content) ? fastApiResponse.Content.SanitizeLogString() : null);
}
return StatusCode((int)fastApiResponse.StatusCode, fastApiResponse.Content);
}
[HttpGet("structure/{projectId:guid}/influence_diagram")]
public async Task<ActionResult<ApiResponseDto>> GetInfluenceDiagramAsync([FromRoute] Guid projectId)
{
UserOutgoingDto user = HttpContext.GetLoadedUser();
var fastApiResponse = await _fastApiService.SendInfluenceDiagramToFastApiAsync(projectId, $"/structure/{projectId}/influence_diagram", user);
if (fastApiResponse.StatusCode == HttpStatusCode.OK)
{
return Ok(!string.IsNullOrEmpty(fastApiResponse.Content) ? fastApiResponse.Content.SanitizeLogString() : null);
}
return StatusCode((int)fastApiResponse.StatusCode, fastApiResponse.Content);
}
[HttpGet("structure/{projectId:guid}/partial_order")]
public async Task<ActionResult<ApiResponseDto>> GetPartialOrderAsync([FromRoute] Guid projectId)
{
UserOutgoingDto user = HttpContext.GetLoadedUser();
var fastApiResponse = await _fastApiService.SendInfluenceDiagramToFastApiAsync(projectId, $"/structure/{projectId}/partial_order", user);
if (fastApiResponse.StatusCode == HttpStatusCode.OK)
{
return Ok(!string.IsNullOrEmpty(fastApiResponse.Content) ? fastApiResponse.Content.SanitizeLogString() : null);
}
return StatusCode((int)fastApiResponse.StatusCode, fastApiResponse.Content);
}
}