@page "/school-subjects/{Id:int}"

@attribute [Authorize]
@using Microsoft.AspNetCore.Authorization
@using WorkManagementTool.Services
@using WorkManagementTool.Data.Entities;

@inject SchoolSubjectService SchoolSubjectService

<h3>SchoolSubject</h3>

@if (schoolSubject is null)
{
    <p>School subject not found</p>
}
else
{
    <dl>
        <dh>Name</dh>
        <dd>@schoolSubject.Name</dd>

        @if (!string.IsNullOrWhiteSpace(schoolSubject.Description))
        {
            <dh>Description:</dh>
            <dd>@schoolSubject.Description</dd>
        }

        <dh>Created At</dh>
        <dd>@schoolSubject.CreatedAt.ToLocalTime()</dd>

        <dh>Actions</dh>
    </dl>
}

@code {
    [Parameter]
    public int Id { get; set; }

    private SchoolSubject? schoolSubject;

    protected override async Task OnInitializedAsync()
    {
        schoolSubject = await SchoolSubjectService.GetSchoolSubjectByIdAsync(Id);

    }
}
