public async Task <IActionResult> GetById(string id) { try { if (string.IsNullOrWhiteSpace(id)) { return(BadRequest("No id provided")); } var record = await repo.GetById(id); if (record == null) { return(NotFound()); } return(Ok(MapMetadataToAIClipMetadata(record))); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } }
public async Task <IActionResult> Get(int id) { var currentUser = HttpContext.User.Identity.Name; var meta = _metadataRepository.GetById(id); if (meta == null) { return(_securityRepository.GateNotFound(currentUser, AccessLogAction.DocumentRead, "Document", id.ToString())); } if (!_securityRepository.UserIsAuthorisedByBuisnessAreas(HttpContext, AuthActions.Return, meta.BuisnessArea)) { return(_securityRepository.GateNotFound(currentUser, AccessLogAction.DocumentRead, "Document", id.ToString())); } var doc = await _documentRepository.GetDocumentAsync(meta); _logger.Log(LogLevel.Debug, "Downloading Document {0} for User {1}", meta.Id, HttpContext.User.Identity.Name); _securityRepository.LogUserAction(currentUser, AccessLogAction.DocumentRead, id, "Document", true); return(Ok(doc)); }
public IActionResult Get(int id, [FromQuery] bool incVersions = false, [FromQuery] bool incArchive = false) { string currentUser = HttpContext.User.Identity.Name; MetadataEntity item = _metadataRepository.GetById(id, incVersions, incArchive); if (item == null) { return(_securityRepository.GateNotFound(currentUser, AccessLogAction.DocumentMetadataRead, "Metadata", id.ToString())); } if (!_securityRepository.UserIsAuthorisedByBuisnessAreas(HttpContext, AuthActions.Return, item.BuisnessArea)) { return(_securityRepository.GateUnathorised(currentUser, AccessLogAction.DocumentMetadataRead, "Metadata", id.ToString())); } _logger.Log(LogLevel.Information, "DocumentMetadata {0} Returned For {1}", item.Id, currentUser); _securityRepository.LogUserAction(currentUser, AccessLogAction.DocumentMetadataRead, id, "Metadata", true); _metadataRepository.Touch(ref item); _metadataRepository.SaveChanges(); return(Ok(item)); }