Files
TechHelper/TechHelper.Client/Pages/Exam/ExamEdit.razor
SpecialX c59762a392
Some checks failed
Tech / explore-gitea-actions (push) Has been cancelled
UI
2025-08-31 11:29:26 +08:00

48 lines
1.2 KiB
Plaintext
Raw Permalink 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.Pages.Exam.ExamView
@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 AssignmentDto ?? new AssignmentDto();
}
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);
}
}
}