forked from equinor/fusion-bmt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuery.cs
136 lines (122 loc) · 4.07 KB
/
Query.cs
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
using HotChocolate.Data;
using System.Linq;
using Microsoft.Extensions.Logging;
using api.Models;
using api.Services;
namespace api.GQL
{
public class GraphQuery
{
private readonly ProjectService _projectService;
private readonly EvaluationService _evaluationService;
private readonly ParticipantService _participantService;
private readonly QuestionService _questionService;
private readonly QuestionTemplateService _questionTemplateService;
private readonly AnswerService _answerService;
private readonly ActionService _actionService;
private readonly NoteService _noteService;
private readonly ClosingRemarkService _closingRemarkService;
private readonly ProjectCategoryService _projectCategoryService;
private readonly ILogger _logger;
public GraphQuery(
ProjectService projectService,
EvaluationService evaluationService,
ParticipantService participantService,
QuestionService questionService,
QuestionTemplateService questionTemplateService,
AnswerService answerService,
ActionService actionService,
NoteService noteService,
ClosingRemarkService closingRemarkService,
ProjectCategoryService projectCategoryService,
ILogger<GraphQuery> logger
)
{
_projectService = projectService;
_evaluationService = evaluationService;
_participantService = participantService;
_questionService = questionService;
_questionTemplateService = questionTemplateService;
_answerService = answerService;
_actionService = actionService;
_noteService = noteService;
_closingRemarkService = closingRemarkService;
_projectCategoryService = projectCategoryService;
_logger = logger;
}
[UseProjection]
[UseFiltering]
public IQueryable<Project> GetProjects()
{
return _projectService.GetAll();
}
public Project GetProject(string fusionProjectID)
{
Project project;
try
{
project = _projectService.GetProjectFromFusionId(fusionProjectID);
}
catch (NotFoundInDBException)
{
project = _projectService.Create(fusionProjectID);
_logger.LogInformation($"Created new project with fusionProjectId: {fusionProjectID}");
}
return project;
}
[UseProjection]
[UseFiltering]
public IQueryable<Evaluation> GetEvaluations()
{
return _evaluationService.GetAll();
}
[UseProjection]
[UseFiltering]
public IQueryable<Participant> GetParticipants()
{
return _participantService.GetAll();
}
[UseProjection]
[UseFiltering]
public IQueryable<Question> GetQuestions()
{
return _questionService.GetAll();
}
[UseProjection]
[UseFiltering]
public IQueryable<QuestionTemplate> GetQuestionTemplates()
{
return _questionTemplateService.GetAll();
}
[UseProjection]
[UseFiltering]
public IQueryable<Answer> GetAnswers()
{
return _answerService.GetAll();
}
[UseProjection]
[UseFiltering]
public IQueryable<Action> GetActions()
{
return _actionService.GetAll();
}
[UseProjection]
[UseFiltering]
public IQueryable<Note> GetNotes()
{
return _noteService.GetAll();
}
[UseProjection]
[UseFiltering]
public IQueryable<ClosingRemark> GetClosingRemarks()
{
return _closingRemarkService.GetAll();
}
[UseProjection]
[UseFiltering]
public IQueryable<ProjectCategory> GetProjectCategory()
{
return _projectCategoryService.GetAll();
}
}
}