@using BTCPayServer.Storage.Services
@using BTCPayServer.Services
@using Microsoft.AspNetCore.Identity
@using BTCPayServer.Data
@inject StoredFileRepository StoredFileRepository
@inject UserManager<ApplicationUser> UserManager
@inject UserService UserService
@{
    var user = await UserManager.GetUserAsync(User);
    var files = (await StoredFileRepository.GetFiles(new StoredFileRepository.FilesQuery()
    {
        UserIds = await UserService.IsAdminUser(user) ? Array.Empty<string>() : new[] {user.Id},
    })).Select(file => new SelectListItem(file.FileName, file.Id)).Prepend(new SelectListItem("No file", ""));
}
<template v-if="editingItem">
    <div class="form-group">
        <label class="form-label">Downloadable file</label>
        <select :value="editingItem['file'] || ''" asp-items="files" class="form-select w-auto" v-on:change="if(event.target.value) Vue.set(editingItem, 'file', event.target.value); else Vue.delete(editingItem, 'file');"></select>
        <span class="form-text">If a file is selected, when a user buys this item, a download link is generated in the payment receipt once the invoice is settled. <a target="_blank" asp-action="Files" asp-controller="UIServer">Upload files here</a></span>
    </div>
</template>