public async Task <AnnotationModel> Add(AnnotationModel model) { var created = await AddAnnotation(model); var manifest = await _manifests.GetByAnnotationSourceId(created.Target.SourceId); var source = await _annotationSources.SingleOrDefaultAsync(s => s.AnnotationSourceId == created.Target.SourceId); RerumManifestResponse rerumResponse = null; // should we care if we save to rerum at this point? try { if (string.IsNullOrWhiteSpace(source.RerumStorageUrl)) { // Post the manifest rerumResponse = await _rerum.PostManifest(manifest); } else { rerumResponse = await _rerum.PutManifest(manifest); } } catch (Exception ex) { _logger.LogError(ex, "An error occurred saving manifest to rerum."); } if (rerumResponse != null && (rerumResponse.Code == 200 || rerumResponse.Code == 201)) { if (source.RerumStorageUrl != rerumResponse.NewObjectState.Id) { source.RerumStorageUrl = rerumResponse.NewObjectState.Id; await _unitOfWork.SaveChangesAsync(); } } return(created); }
public async Task <IActionResult> GetByAnnotatonSourceId(long id) { var model = await _webManifestService.GetByAnnotationSourceId(id); return(Ok(model)); }