public IActionResult DeleteFileDataById(string fileId) { if (!Guid.TryParse(fileId, out Guid id)) { return(BadRequest("Invalid file id")); } var userIdClaim = User.Claims.Single(c => c.Type == "id"); var fileMetadata = _fileData.GetFileMetadata(id); if (fileMetadata == null) { return(BadRequest("File not found")); } if (userIdClaim.Value != fileMetadata.Audit.CreatedUserId) { return(Unauthorized("User does not own the file")); } _fileData.Delete(id); _fileData.Delete(fileMetadata); return(NoContent()); }