@using Entities.DTO
@using Microsoft.AspNetCore.Authorization
@using TechHelper.Client.Exam
@using TechHelper.Client.Pages.Common.Exam

@page "/exam/manage"
@using Entities.DTO
@using TechHelper.Client.Services
@attribute [Authorize]


@if (isloding)
{
	<MudText> 正在加载 </MudText>
}
else
{

}

<MudPaper Class="d-flex flex-wrap flex-grow-0 gap-4" Height="100%" Width="100%">
	@foreach (var item in examDtos)
	{
	}
</MudPaper>

@code {
	[Inject]
	public IExamService ExamService { get; set; }

	[Inject]
	public ISnackbar Snackbar { get; set; }

	[CascadingParameter]
	private Task<AuthenticationState> authenticationStateTask { get; set; }

	private List<AssignmentDto> examDtos = new List<AssignmentDto>();

	private bool isloding = true;

	protected override async Task OnInitializedAsync()
	{
		GetExam();
	}


	private async void GetExam()
	{
		isloding = true;
		Snackbar.Add("正在加载", Severity.Info);
		var result = await ExamService.GetAllExam();
		if (result.Status)
		{
			examDtos = result.Result as List<AssignmentDto> ?? new List<AssignmentDto>();
			Snackbar.Add("加载成功", Severity.Info);
		}
		else
		{
			Snackbar.Add($"加载失败 {result.Message}", Severity.Error);
		}
		isloding = false;
		StateHasChanged();
	}
}
