private async Task LoadExamList() { var(code, res) = await ExamServices.GetExams(3); if (code == ErrorCodes.Success) { _examList = res; return; } if (code == ErrorCodes.NotLoggedIn) { await Modal.ErrorAsync(new ConfirmOptions() { Title = "Please login first", }); NavManager.NavigateTo("/User/Login"); } else { await Modal.ErrorAsync(new ConfirmOptions() { Title = "Failed to get exam list", Content = ErrorCodes.MessageMap[code] }); } }
private async Task LoadExamList() { var(code, res) = await ExamServices.GetExams(1); if (code == ErrorCodes.Success) { _examList = res; foreach (var e in _examList) { if (e.StartTime < DateTime.Now && e.StartTime.AddSeconds(e.Duration) > DateTime.Now && e.BanReason == null) { _nextExam = e; _haveOngoingExam = true; break; } if (e.StartTime > DateTime.Now && e.BanReason == null) { if (_nextExam == null || (_nextExam.StartTime - DateTime.Now) > (e.StartTime - DateTime.Now)) { _nextExam = e; } } } return; } if (code == ErrorCodes.NotLoggedIn) { await Modal.ErrorAsync(new ConfirmOptions() { Title = "Please login first", }); NavManager.NavigateTo("/User/Login"); } else { await Modal.ErrorAsync(new ConfirmOptions() { Title = "Failed to get exam list", Content = ErrorCodes.MessageMap[code] }); } }