Files
TechHelper/TechHelper.Client/Pages/Exam/ExamEdit.razor
2025-06-20 15:37:39 +08:00

47 lines
1.2 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@page "/exam/edit/{ExamId}"
@using Entities.DTO
@using TechHelper.Client.Services
@using Entities.DTO
@using TechHelper.Client.Exam
<ExamView ParsedExam="@ExamDto"/>
@code {
[Parameter]
public string ExamId { get; set; }
[Inject]
public IExamService ExamService { get; set; }
[Inject]
private NavigationManager Navigation { get; set; }
[Inject]
private ISnackbar Snackbar { get; set; }
private AssignmentDto ExamDto { get; set; }
protected override async Task OnInitializedAsync()
{
if (Guid.TryParse(ExamId, out Guid parsedExamId))
{
Console.WriteLine($"ExamId 字符串成功解析为 Guid: {parsedExamId}");
try
{
// var result = await ExamService.GetExam(parsedExamId);
// if (result.Status) ExamDto = result.Result as ExamDto ?? new ExamDto();
}
catch (Exception ex)
{
Snackbar?.Add($"获取试卷失败: {ex.Message}", Severity.Error);
}
}
else
{
Console.Error.WriteLine($"错误:路由参数 ExamId '{ExamId}' 不是一个有效的 GUID 格式。无法获取试卷信息。");
Navigation.NavigateTo("/exam/manager");
Snackbar?.Add("无效的试卷ID无法加载。", Severity.Error);
}
}
}