This commit is contained in:
@@ -20,7 +20,16 @@ namespace TechHelper.Client.Services
|
||||
|
||||
public Task<ResponseDto> CreateClass(UserRegistrationToClassDto userClass)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
try
|
||||
{
|
||||
return Task.FromResult(new ResponseDto { IsSuccessfulRegistration = true });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// 实际应用中,这里应该加入日志记录
|
||||
Console.WriteLine($"Error in CreateClass: {ex.Message}");
|
||||
return Task.FromResult(new ResponseDto { IsSuccessfulRegistration = false, Errors = new string[] { ex.Message } });
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ApiResponse> GetClassStudents()
|
||||
@@ -56,7 +65,25 @@ namespace TechHelper.Client.Services
|
||||
|
||||
public StudentDto GetStudents(byte Class)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
try
|
||||
{
|
||||
var result = _client.PostAsJsonAsync("class/getClassStudents", Class);
|
||||
var content = result.Result.Content.ReadAsStringAsync();
|
||||
if (content.Result != null)
|
||||
{
|
||||
var users = JsonConvert.DeserializeObject<StudentDto>(content.Result);
|
||||
return users;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new StudentDto();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"获取失败,{ex.Message}, InnerException: {ex.InnerException}");
|
||||
return new StudentDto();
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<ResponseDto> UserRegister(UserRegistrationToClassDto userRegistrationToClassDto)
|
||||
|
Reference in New Issue
Block a user