@page "/Tools/{id:guid}"
@page "/Tools/{id:guid}/General"
@page "/Tools/Add"
@using LANCommander.SDK.Enums
@using LANCommander.Server.UI.Pages.Tools.Components
@attribute [Authorize(Roles = RoleService.AdministratorRoleName)]
@inject GameService GameService
@inject ToolService ToolService
@inject ModalService ModalService
@if (Id == Guid.Empty)
{
Add New Tool
}
else
{
General
}
@if (context != null && context.Id != Guid.Empty)
{
}
@if (context != null)
{
}
@code {
[Parameter] public Guid Id { get; set; }
ICollection Games;
ToolEditView EditView;
bool _openingExportDialog;
protected override async Task OnInitializedAsync()
{
Games = await GameService
.AsNoTracking()
.Include(g => g.Media)
.SortBy(g => String.IsNullOrWhiteSpace(g.SortTitle) ? g.Title : g.SortTitle)
.GetAsync(g => g.Type == GameType.MainGame || g.Type == GameType.StandaloneExpansion || g.Type == GameType.StandaloneMod || g.BaseGame == null);
Games = Games.OrderByTitle(g => String.IsNullOrWhiteSpace(g.SortTitle) ? g.Title : g.SortTitle).ToList();
}
private async Task OpenExportDialog()
{
_openingExportDialog = true;
await InvokeAsync(StateHasChanged);
await Task.Yield();
var tool = await ToolService.GetAsync(Id);
var modalOptions = new ModalOptions()
{
Title = $"Export {tool.Name}",
Maximizable = false,
DefaultMaximized = false,
Closable = true,
OkText = "Add",
Footer = null,
};
var options = new ExportDialogOptions()
{
RecordId = Id,
RecordType = ImportExportRecordType.Tool
};
var modalRef = await ModalService.CreateModalAsync(modalOptions, options);
_openingExportDialog = false;
await InvokeAsync(StateHasChanged);
await Task.Yield();
}
}