Revize 4540d7b6
Přidáno uživatelem Vojtěch Bartička před téměř 3 roky(ů)
Backend/Backend/Controllers/DocumentController.cs | ||
---|---|---|
232 | 232 |
} |
233 | 233 |
} |
234 | 234 |
|
235 |
[HttpDelete("/documents/{documentId}/annotators/{annotatorId}")] |
|
236 |
[Authorize(Models.Enums.ERole.ADMINISTRATOR)] |
|
237 |
[ProducesResponseType((int)HttpStatusCode.OK)] |
|
238 |
[ProducesResponseType((int)HttpStatusCode.Forbidden)] |
|
239 |
public ActionResult RemoveAnnotatorFromDocument([FromServices] ClientInfo clientInfo, Guid documentId, Guid annotatorId) |
|
240 |
{ |
|
241 |
if (clientInfo.LoggedUser == null) |
|
242 |
{ |
|
243 |
logger.Warning("ClientInfo has null LoggerUser in [Authorized] controller /annotations"); |
|
244 |
return Problem(); |
|
245 |
} |
|
246 |
|
|
247 |
try |
|
248 |
{ |
|
249 |
documentService.RemoveAnnotatorFromDocument(documentId, annotatorId); |
|
250 |
return Ok(); |
|
251 |
} |
|
252 |
catch (InvalidOperationException e) |
|
253 |
{ |
|
254 |
throw new BadRequestException("Could not find specified annotation"); |
|
255 |
} |
|
256 |
|
|
257 |
} |
|
258 |
|
|
235 | 259 |
[HttpPost("/documents/export")] |
236 | 260 |
[Authorize(Models.Enums.ERole.ADMINISTRATOR)] |
237 | 261 |
[ProducesResponseType((int)HttpStatusCode.OK)] |
Backend/Core/Services/DocumentService/DocumentServiceEF.cs | ||
---|---|---|
176 | 176 |
}; |
177 | 177 |
} |
178 | 178 |
|
179 |
public void RemoveAnnotatorFromDocument(Guid documentId, Guid annotatorId) |
|
180 |
{ |
|
181 |
var document = databaseContext.Documents.Single(d => d.Id == documentId); |
|
182 |
var annotation = databaseContext.Annotations.Single(a => a.Document == document && a.User.Id == annotatorId ); |
|
183 |
|
|
184 |
databaseContext.Annotations.Remove(annotation); |
|
185 |
databaseContext.SaveChanges(); |
|
186 |
} |
|
187 |
|
|
179 | 188 |
public void SetRequiredAnnotationsForDocuments(SetRequiredAnnotationsRequest request) |
180 | 189 |
{ |
181 | 190 |
var documents = databaseContext.Documents.Where(d => request.DocumentIds.Contains(d.Id)); |
Backend/Core/Services/DocumentService/IDocumentService.cs | ||
---|---|---|
18 | 18 |
public void SetRequiredAnnotationsForDocuments(SetRequiredAnnotationsRequest request); |
19 | 19 |
public void SetRequiredAnnotationsGlobal(int requiredAnnotations); |
20 | 20 |
public int GetRequiredAnnotationsGlobal(); |
21 |
public void RemoveAnnotatorFromDocument(Guid documentId, Guid annotatorId); |
|
21 | 22 |
} |
22 | 23 |
} |
Také k dispozici: Unified diff
Added endpoint for removing annotator from document