Files
WotBlitzStatisticsBlazor/WotBlitzStatisticsPro.Logic/WargamingSearch.cs
T

59 lines
1.8 KiB
C#
Raw Normal View History

using System.Collections.Generic;
using System.Threading.Tasks;
using AutoMapper;
using WotBlitzStatisticsPro.Common.Model;
using WotBlitzStatisticsPro.WgApiClient;
using WotBlitzStatisticsPro.WgApiClient.Model;
2020-05-23 11:43:14 +02:00
namespace WotBlitzStatisticsPro.Logic
{
public class WargamingSearch : IWargamingSearch
{
private readonly IWargamingApiClient _wargamingApiClient;
private readonly IMapper _mapper;
public WargamingSearch(IWargamingApiClient wargamingApiClient, IMapper mapper)
{
_wargamingApiClient = wargamingApiClient;
_mapper = mapper;
}
public async Task<AccountsSearchResponse> FindAccounts(
string accountNick,
RealmType realmType,
RequestLanguage language)
{
var response = await _wargamingApiClient.FindAccounts(accountNick, realmType, language);
2020-12-27 12:39:25 +01:00
if (response == null)
{
return new AccountsSearchResponse();
}
return new AccountsSearchResponse
{
AccountsCount = response.Count,
Accounts = _mapper.Map<List<WotAccountListResponse>, List<AccountsSearchResponseItem>>(response)
};
}
2020-05-19 14:22:47 +02:00
public async Task<ClanSearchResponse> FindClans(
string searchString,
RealmType realmType,
RequestLanguage language)
{
var response = await _wargamingApiClient.FindClans(searchString, realmType, language);
2020-12-27 12:39:25 +01:00
if (response == null)
{
return new ClanSearchResponse();
}
2020-05-19 14:22:47 +02:00
return new ClanSearchResponse
{
ClansCount = response.Count,
Clans = _mapper.Map<List<WotClanListResponse>, List<ClanSearchResponseItem>>(response)
};
}
}
}