mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-25 03:10:07 +01:00
feat: clan query implemented
This commit is contained in:
1 parent
8fb1b170df
commit
af747cf3f4
7 files changed
+97
-8
No files matched your search
@@ -1,18 +1,48 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
using WotBlitzStatisticsPro.DataAccess;
|
||||
using WotBlitzStatisticsPro.WgApiClient;
|
||||
using WotBlitzStatisticsPro.WgApiClient.Model;
|
||||
|
||||
namespace WotBlitzStatisticsPro.Logic
|
||||
{
|
||||
public class WargamingClans: IWargamingClans
|
||||
{
|
||||
private const RealmType DefaultRealm = RealmType.Ru;
|
||||
private const RequestLanguage DefaultRequestLanguage = RequestLanguage.En;
|
||||
private readonly IDictionariesDataAccessor _dictionariesDataAccessor;
|
||||
private readonly IWargamingApiClient _wargamingApiClient;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
public Task<ClanInfoResponse> GelClanInfoByAccount(long accountId, RealmAndLanguage queryParams)
|
||||
public WargamingClans(
|
||||
IDictionariesDataAccessor dictionariesDataAccessor,
|
||||
IWargamingApiClient wargamingApiClient,
|
||||
IMapper mapper)
|
||||
{
|
||||
// ToDo: Make Wargaming request
|
||||
return Task.FromResult(new ClanInfoResponse {ClanId = 42, Name = "Fake clan"});
|
||||
_dictionariesDataAccessor = dictionariesDataAccessor;
|
||||
_wargamingApiClient = wargamingApiClient;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
public async Task<ClanInfoResponse?> GelClanInfoByAccount(long accountId, RealmAndLanguage queryParams)
|
||||
{
|
||||
var clanRoles = await _dictionariesDataAccessor.GetClanRoles(queryParams.Language);
|
||||
var accountClanInfo =
|
||||
await _wargamingApiClient.GetPlayerClanInfo(accountId, queryParams.Realm, queryParams.Language);
|
||||
if (accountClanInfo?.ClanId == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var result = _mapper.Map<ClanAccountInfo, ClanInfoResponse>(accountClanInfo,
|
||||
opt => opt.Items["roles"] = clanRoles);
|
||||
|
||||
var clanInfo = await _wargamingApiClient.GetClanInfo(accountClanInfo.ClanId.Value, queryParams.Realm,
|
||||
queryParams.Language);
|
||||
|
||||
_mapper.Map(clanInfo, result);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user