Revize 9190add5
Přidáno uživatelem Vojtěch Bartička před téměř 3 roky(ů)
Backend/Backend/Controllers/AnnotationController.cs | ||
---|---|---|
7 | 7 |
using Serilog; |
8 | 8 |
using Core.Services.AnnotationService; |
9 | 9 |
using RestAPI.Exceptions; |
10 |
using Models.Tags; |
|
11 |
using Core.Services.TagService; |
|
12 |
|
|
10 | 13 |
|
11 | 14 |
namespace RestAPI.Controllers |
12 | 15 |
{ |
... | ... | |
14 | 17 |
{ |
15 | 18 |
private readonly Serilog.ILogger logger; |
16 | 19 |
private readonly IAnnotationService annotationService; |
20 |
private readonly ITagService tagService; |
|
17 | 21 |
|
18 |
public AnnotationController(Serilog.ILogger logger, IAnnotationService annotationService) |
|
22 |
public AnnotationController(Serilog.ILogger logger, IAnnotationService annotationService, ITagService tagService)
|
|
19 | 23 |
{ |
20 | 24 |
this.logger = logger; |
21 | 25 |
this.annotationService = annotationService; |
26 |
this.tagService = tagService; |
|
22 | 27 |
} |
23 | 28 |
|
24 | 29 |
[HttpPost("/annotations")] |
... | ... | |
131 | 136 |
} |
132 | 137 |
|
133 | 138 |
} |
139 |
|
|
140 |
[HttpPost("/annotation/{annotationId}/tag/{occurenceId}/note")] |
|
141 |
[ProducesResponseType((int)HttpStatusCode.OK)] |
|
142 |
[ProducesResponseType((int)HttpStatusCode.Forbidden)] |
|
143 |
public ActionResult AddNoteToTagOccurence([FromServices] ClientInfo clientInfo, Guid annotationId, Guid occurenceId, |
|
144 |
[FromBody] AddNoteToTagOccurenceRequest request) |
|
145 |
{ |
|
146 |
if (clientInfo.LoggedUser == null) |
|
147 |
{ |
|
148 |
logger.Warning("ClientInfo has null LoggerUser in [Authorized] controller /annotations"); |
|
149 |
return Problem(); |
|
150 |
} |
|
151 |
|
|
152 |
// Take care of - non-admin user requesting not-assigned annotation |
|
153 |
// non-existent annotation |
|
154 |
try |
|
155 |
{ |
|
156 |
tagService.AddAnnotationInstance(annotationId, occurenceId, clientInfo.LoggedUser, request); |
|
157 |
return Ok(); |
|
158 |
} |
|
159 |
catch (InvalidOperationException e) |
|
160 |
{ |
|
161 |
throw new BadRequestException("Could not find specified annotation"); |
|
162 |
} |
|
163 |
catch (UnauthorizedAccessException) |
|
164 |
{ |
|
165 |
return Forbid(); |
|
166 |
} |
|
167 |
|
|
168 |
} |
|
134 | 169 |
} |
135 | 170 |
} |
Také k dispozici: Unified diff
Added endpoint for adding notes to tags in AnnotationController