@page "/Account/Manage/Class"
@using System.ComponentModel.DataAnnotations
@using Entities.Contracts
@using Microsoft.AspNetCore.Identity


<PageTitle>Profile</PageTitle>

@if (authenticationStateTask.Result.User.FindFirst("Class")?.Value == null)
{

	<EditForm Model="@_userRegistrationToClassDto" OnValidSubmit="Register" FormName="ClassForm">
		<DataAnnotationsValidator />
		<MudGrid>
			<MudItem xs="12" sm="7">
				<MudCard>
					<MudCardContent>
						<MudRadioGroup T="UserRoles" Label="Roles" @bind-Value="_userRegistrationToClassDto.Roles">
							@foreach (UserRoles item in Enum.GetValues(typeof(UserRoles)))
							{
								if (item != UserRoles.Administrator)
								{
									<MudRadio Value="@item">@item.ToString()</MudRadio>
								}
							}
						</MudRadioGroup>
						<MudTextField Label="Grade" Class="mt-3"
									  @bind-Value="_userRegistrationToClassDto.GradeId" For="@(() => _userRegistrationToClassDto.GradeId)" />
						<MudTextField Label="Class" HelperText="请输入你的班级" Class="mt-3"
									  @bind-Value="_userRegistrationToClassDto.ClassId" For="@(() => _userRegistrationToClassDto.ClassId)" />

						@if (_userRegistrationToClassDto.Roles == UserRoles.Teacher)
						{
							<MudSelect @bind-Value="_userRegistrationToClassDto.SubjectArea" Label="Select Subject" AdornmentColor="Color.Secondary">
								@foreach (SubjectAreaEnum item in Enum.GetValues(typeof(SubjectAreaEnum)))
								{
									<MudSelectItem Value="@item">@item</MudSelectItem>
								}
							</MudSelect>
						}
					</MudCardContent>
					<MudCardActions>
						<MudButton ButtonType="ButtonType.Submit" Variant="Variant.Filled" Color="Color.Primary" Class="ml-auto">Register</MudButton>
					</MudCardActions>
				</MudCard>
			</MudItem>
		</MudGrid>
	</EditForm>


}
else
{
	<MudPaper>
		<MudText Class="ma-3 pa-3"> 年级 : @authenticationStateTask.Result.User.FindFirst("Grade")?.Value.ToString() </MudText>
		<MudText Class="ma-3 pa-3"> 班级 : @authenticationStateTask.Result.User.FindFirst("Class")?.Value.ToString() </MudText>
	</MudPaper>
}
<RestoreUserRole></RestoreUserRole>