LANCommander/LANCommander.Server/UI/Pages/Games/Edit/Mods.razor

47 lines
2.2 KiB
Text

@page "/Games/{id:guid}/Mods"
@attribute [Authorize(Roles = RoleService.AdministratorRoleName)]
@inject GameService GameService
@inject IMessageService MessageService
@inject NavigationManager NavigationManager
@inject ILogger<Mods> Logger
<GameEditView Id="Id" Title="Mods">
<Table TItem="Game" DataSource="@context.DependentGames.Where(g => g.Type == GameType.Mod)" Context="mod" Responsive>
<PropertyColumn Property="e => e.Title" Sortable Filterable />
<PropertyColumn Property="e => e.SortTitle" Sortable Filterable />
<PropertyColumn Property="e => e.ReleasedOn" Format="MM/dd/yyyy" Sortable Filterable />
<PropertyColumn Property="e => e.CreatedOn" Format="MM/dd/yyyy" Sortable Filterable />
<PropertyColumn Property="e => e.CreatedBy != null ? e.CreatedBy.UserName : String.Empty" Sortable Filterable Title="Created By" />
<PropertyColumn Property="e => e.UpdatedOn" Format="MM/dd/yyyy" Sortable Filterable />
<PropertyColumn Property="e => e.UpdatedBy != null ? e.UpdatedBy.UserName : String.Empty" Sortable Filterable Title="Created By" />
<ActionColumn Style="text-align: right">
<Space Direction="SpaceDirection.Horizontal">
<SpaceItem>
<Button Type="ButtonType.Primary" OnClick="@(() => NavigationManager.NavigateTo($"/Games/{mod.Id}", true))">Edit</Button>
</SpaceItem>
<SpaceItem>
<Popconfirm OnConfirm="() => Delete(mod)" Title="Are you sure you want to delete this mod?">
<Button Icon="@IconType.Outline.Close" Type="ButtonType.Text" Danger />
</Popconfirm>
</SpaceItem>
</Space>
</ActionColumn>
</Table>
</GameEditView>
@code {
[Parameter] public Guid Id { get; set; }
private async Task Delete(Game game)
{
try
{
await GameService.DeleteAsync(game);
}
catch (Exception ex)
{
MessageService.Error($"Could not delete the {game.Type.GetDisplayName().ToLower()}!");
Logger.LogError(ex, $"Could not delete the {game.Type.GetDisplayName().ToLower()}!");
}
}
}