Exemplo n.º 1
0
        public async Task <IActionResult> Delete(string fileKey)
        {
            try
            {
                var  userKey           = _contextAccessor.UserKeyFromContext();
                bool userCanAccessFile = await UserCanAccessFile(userKey, fileKey, _hiarcDatabase, AccessLevelGroup.ReadWriteOrHigher);

                if (userCanAccessFile)
                {
                    await _hiarcDatabase.DeleteFile(fileKey);

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