Example #1
0
        public async Task <IActionResult> GetFiles(string key)
        {
            try
            {
                var  userKey = _contextAccessor.UserKeyFromContext();
                bool userCanAccessCollection = await UserCanAccessCollection(userKey, key, _hiarcDatabase, AccessLevelGroup.ReadOnlyOrHigher);

                if (userCanAccessCollection)
                {
                    var theFiles = await _hiarcDatabase.GetFilesForCollection(key);

                    return(Ok(theFiles));
                }
                else
                {
                    return(StatusCode(StatusCodes.Status403Forbidden));
                }
            }
            catch (InvalidOperationException ex)
            {
                _logger.LogError(ex.Message);
                return(StatusCode(StatusCodes.Status403Forbidden));
            }
            catch (Exception ex)
            {
                return(BuildErrorResponse(ex, _logger));
            }
        }