Files
TechHelper/TechHelper.Client/Services/CommonService.cs
SpecialX ac900159ba
Some checks failed
TechAct / explore-gitea-actions (push) Failing after 12s
重构项目结构,移除Assignment相关功能,优化Submission模块
2025-10-09 18:57:28 +08:00

48 lines
1.3 KiB
C#

using Entities.Contracts;
using Entities.DTO;
using System.Net.Http.Json;
using TechHelper.Client.HttpRepository;
namespace TechHelper.Client.Services
{
public class CommonService : ICommonService
{
private readonly HttpClient _client;
private readonly IAuthenticationClientService _authenticationClientService;
public CommonService(HttpClient client, IAuthenticationClientService authenticationClientService)
{
_client = client;
_authenticationClientService = authenticationClientService;
}
public async Task<List<TypeCommonDto>> GetCommonTypesAsync(TypeNameType typeNameType, Guid? SubjectId = null)
{
switch (typeNameType)
{
case TypeNameType.Subject:
{
var response = await _client.GetAsync("subject");
var result = await response.Content.ReadFromJsonAsync<List<TypeCommonDto>>();
return result;
}
case TypeNameType.ExamType:
{
var response = await _client.GetAsync("exam-type");
var result = await response.Content.ReadFromJsonAsync<List<TypeCommonDto>>();
return result;
}
case TypeNameType.QuestionType:
{
var response = await _client.GetAsync("question-type");
var result = await response.Content.ReadFromJsonAsync<List<TypeCommonDto>>();
return result;
}
}
throw new NotImplementedException();
}
}
}