@using Entities.DTO
@inject ISnackbar Snackbar
@using Entities.Contracts



<MudDialog Class="rounded-xl pa-2" Style="background-color: #dedede">
	<TitleContent>
		<MudText Typo="Typo.h6">
			<MudIcon Icon="@Icons.Material.Filled.EditAttributes" Class="mr-3 mb-n1" />
			<b> 发布! </b>
		</MudText>
	</TitleContent>
	<DialogContent>
		<MudPaper Elevation="0" Class="rounded-xl pa-1 " Style="background-color: transparent">
			<MudPaper Elevation="0" Class="rounded-xl pa-2 ma-2">
				<MudTextField @bind-Value="Exam.Name" Label="Title" Variant="Variant.Text" Margin="Margin.Dense" AutoFocus="true" />
				<MudTextField @bind-Value="Exam.TotalQuestions" Label="TotalQuestions" Variant="Variant.Text" Adornment="Adornment.End" AdornmentText="." Margin="Margin.Dense" AutoFocus="true" />
				<MudTextField @bind-Value="Exam.Score" Label="Score" Variant="Variant.Text" Adornment="Adornment.End" AdornmentText="." Margin="Margin.Dense" AutoFocus="true" />
			</MudPaper>
			<MudPaper Elevation="0" Class="rounded-xl pa-2 ma-2">

				<MudChipSet T="SubjectAreaEnum" @bind-SelectedValue="@Exam.SubjectArea" CheckMark=true SelectionMode="SelectionMode.SingleSelection" Size="Size.Small">
					<MudChip Text="@SubjectAreaEnum.Literature.ToString()" Color="Color.Primary" Value="@SubjectAreaEnum.Literature">    @SubjectAreaEnum.Literature</MudChip>
					<MudChip Text="@SubjectAreaEnum.Mathematics.ToString()" Color="Color.Secondary" Value="@SubjectAreaEnum.Mathematics">  @SubjectAreaEnum.Mathematics</MudChip>
					<MudChip Text="@SubjectAreaEnum.English.ToString()" Color="Color.Info" Value="@SubjectAreaEnum.English">            @SubjectAreaEnum.English</MudChip>
					<MudChip Text="@SubjectAreaEnum.ComputerScience.ToString()" Color="Color.Success" Value="@SubjectAreaEnum.ComputerScience">     @SubjectAreaEnum.ComputerScience</MudChip>
				</MudChipSet>


			</MudPaper>
			<MudPaper Elevation="0" Class="rounded-xl pa-2 ma-2">

				<MudChipSet T="ExamType" @bind-SelectedValue="@Exam.ExamType" CheckMark=true SelectionMode="SelectionMode.SingleSelection" Size="Size.Small">
					<MudChip Text="@ExamType.DailyTest.ToString()" Color="Color.Primary"			Value="@ExamType.DailyTest">       @ExamType.DailyTest</MudChip>
					<MudChip Text="@ExamType.WeeklyExam.ToString()" Color="Color.Secondary"		Value="@ExamType.WeeklyExam">     @ExamType.WeeklyExam</MudChip>
					<MudChip Text="@ExamType.MonthlyExam.ToString()" Color="Color.Info"			Value="@ExamType.MonthlyExam">          @ExamType.MonthlyExam</MudChip>
					<MudChip Text="@ExamType.MidtermExam.ToString()" Color="Color.Success"		Value="@ExamType.MidtermExam">       @ExamType.MidtermExam</MudChip>
					<MudChip Text="@ExamType.FinalExam.ToString()" Color="Color.Warning"			Value="@ExamType.FinalExam">       @ExamType.FinalExam</MudChip>
					<MudChip Text="@ExamType.AITest.ToString()" Color="Color.Error"				Value="@ExamType.AITest">       @ExamType.AITest</MudChip>
				</MudChipSet>
			</MudPaper>
		</MudPaper>
	</DialogContent>
	<DialogActions>
		<MudButton OnClick="Cancel">Cancel</MudButton>
		<MudButton Color="Color.Error" OnClick="Confirm">确认</MudButton>
	</DialogActions>
</MudDialog>

@code {
	[CascadingParameter]
	private IMudDialogInstance MudDialog { get; set; }

	[Parameter]
	public AssignmentDto Exam { get; set; } = new AssignmentDto();


	public SubjectAreaEnum SubjectArea { get; set; }
	private void Cancel() => MudDialog.Cancel();

	private void Confirm()
	{
		Snackbar.Add("属性已更新", Severity.Success);
		MudDialog.Close(DialogResult.Ok(Exam));
	}
}