51 lines
2.1 KiB
Text
51 lines
2.1 KiB
Text
@page "/Games/{id:guid}/Expansions"
|
|
@attribute [Authorize(Roles = RoleService.AdministratorRoleName)]
|
|
@inject GameService GameService
|
|
@inject IMessageService MessageService
|
|
@inject NavigationManager NavigationManager
|
|
@inject ILogger<Expansions> Logger
|
|
|
|
<GameEditView Id="Id" Title="Expansions">
|
|
<DataTable
|
|
TItem="Game"
|
|
Context="expansion"
|
|
Query="g => g.BaseGameId == Id && g.Type == GameType.Expansion">
|
|
<BoundDataColumn Property="e => e.Title" Sortable Filterable />
|
|
<BoundDataColumn Property="e => e.SortTitle" Sortable Filterable />
|
|
<BoundDataColumn Property="s => s.ReleasedOn" Format="MM/dd/yyyy" Sortable Filterable>
|
|
<LocalTime Value="context.ReleasedOn" Format="MM/dd/yyyy" />
|
|
</BoundDataColumn>
|
|
<BoundDataColumn Property="s => s.CreatedOn" Sortable Filterable>
|
|
<LocalTime Value="context.CreatedOn" />
|
|
</BoundDataColumn>
|
|
<BoundDataColumn Property="e => e.CreatedBy.UserName" Sortable Filterable Include="CreatedBy" />
|
|
<BoundDataColumn Property="s => s.UpdatedOn" Sortable Filterable>
|
|
<LocalTime Value="context.UpdatedOn" />
|
|
</BoundDataColumn>
|
|
<BoundDataColumn Property="e => e.UpdatedBy.UserName" Sortable Filterable Include="CreatedBy" />
|
|
<DataActions TData="string">
|
|
<Button Type="ButtonType.Primary" OnClick="@(() => NavigationManager.NavigateTo($"/Games/{expansion.Id}", true))">Edit</Button>
|
|
|
|
<Popconfirm OnConfirm="() => Delete(expansion)" Title="Are you sure you want to delete this expansion?">
|
|
<Button Icon="@IconType.Outline.Close" Type="ButtonType.Text" Danger/>
|
|
</Popconfirm>
|
|
</DataActions>
|
|
</DataTable>
|
|
</GameEditView>
|
|
|
|
@code {
|
|
[Parameter] public Guid Id { get; set; }
|
|
|
|
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()}!");
|
|
}
|
|
}
|
|
}
|