@page "/events/details"
@attribute [Authorize]
@using Microsoft.EntityFrameworkCore
@inject AppDbContext context
@inject NavigationManager NavigationManager

<PageTitle>Details</PageTitle>

<h1>Details</h1>

<div>
    <h2>EventDefinition</h2>
    <hr />
    @if (eventdefinition is null)
    {
        <p><em>Loading...</em></p>
    }
    else {
        <dl class="row">
            <dt class="col-sm-2">Name</dt>
            <dd class="col-sm-10">@eventdefinition.Name</dd>
            <dt class="col-sm-2">ShortName</dt>
            <dd class="col-sm-10">@eventdefinition.ShortName</dd>
            <dt class="col-sm-2">EventFormat</dt>
            <dd class="col-sm-10">@eventdefinition.EventFormat</dd>
            <dt class="col-sm-2">MinTeamSize</dt>
            <dd class="col-sm-10">@eventdefinition.MinTeamSize</dd>
            <dt class="col-sm-2">MaxTeamSize</dt>
            <dd class="col-sm-10">@eventdefinition.MaxTeamSize</dd>
            <dt class="col-sm-2">SemifinalistActivity</dt>
            <dd class="col-sm-10">@eventdefinition.SemifinalistActivity</dd>
            <dt class="col-sm-2">Notes</dt>
            <dd class="col-sm-10">@eventdefinition.Notes</dd>
            <dt class="col-sm-2">ChapterEligibilityCountState</dt>
            <dd class="col-sm-10">@eventdefinition.ChapterEligibilityCountState</dd>
            <dt class="col-sm-2">RegionalEvent</dt>
            <dd class="col-sm-10">@eventdefinition.RegionalEvent</dd>
            <dt class="col-sm-2">RegionalPresubmit</dt>
            @* <dd class="col-sm-10">@eventdefinition.RegionalPresubmit</dd> *@
            <dt class="col-sm-2">Presubmission</dt>
            <dd class="col-sm-10">@eventdefinition.Presubmission</dd>
            <dt class="col-sm-2">StatePretesting</dt>
            @* <dd class="col-sm-10">@eventdefinition.StatePretesting</dd> *@
            <dt class="col-sm-2">StatePreliminaryRound</dt>
            @* <dd class="col-sm-10">@eventdefinition.StatePreliminaryRound</dd> *@
            <dt class="col-sm-2">Documentation</dt>
            <dd class="col-sm-10">@eventdefinition.Documentation</dd>
            <dt class="col-sm-2">Eligibility</dt>
            <dd class="col-sm-10">@eventdefinition.Eligibility</dd>
            <dt class="col-sm-2">Theme</dt>
            <dd class="col-sm-10">@eventdefinition.Theme</dd>
            <dt class="col-sm-2">Description</dt>
            <dd class="col-sm-10">@eventdefinition.Description</dd>
            <dt class="col-sm-2">LevelOfEffort</dt>
            <dd class="col-sm-10">@eventdefinition.LevelOfEffort</dd>
        </dl>
        <div>
            <a href="@($"/eventdefinitions/edit?id={eventdefinition.Id}")">Edit</a> |
            <a href="@($"/events")">Back to List</a>
        </div>
    }
</div>

@code {
    private EventDefinition? eventdefinition;

    [SupplyParameterFromQuery]
    private int Id { get; set; }

    protected override async Task OnInitializedAsync()
    {
        eventdefinition = await context.Events.FirstOrDefaultAsync(m => m.Id == Id);

        if (eventdefinition is null)
        {
            NavigationManager.NavigateTo("notfound");
        }
    }
}
