48 lines
1.3 KiB
C#
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();
|
|
}
|
|
}
|
|
}
|