mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-24 03:40:07 +02:00
CLeanup and restructurisation
This commit is contained in:
1 parent
bfb9f11035
commit
8faccd45c9
104 files changed
+124
-2056
No files matched your search
@@ -0,0 +1,11 @@
|
||||
using System.Threading.Tasks;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
|
||||
namespace WotBlitzStatisticsPro.Logic
|
||||
{
|
||||
public interface IWargamingDictionaries
|
||||
{
|
||||
Task<UpdateDictionariesResponseItem[]> UpdateDictionaries(
|
||||
UpdateDictionariesRequest updateDictionariesRequest);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Threading.Tasks;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
using WotBlitzStatisticsPro.WgApiClient.Model;
|
||||
|
||||
namespace WotBlitzStatisticsPro.Logic
|
||||
{
|
||||
public interface IWargamingSearch
|
||||
{
|
||||
Task<AccountsSearchResponse> FindAccounts(
|
||||
string accountNick,
|
||||
RealmType realmType,
|
||||
RequestLanguage language);
|
||||
|
||||
Task<ClanSearchResponse> FindClans(
|
||||
string searchString,
|
||||
RealmType realmType,
|
||||
RequestLanguage language);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using AutoMapper;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
using WotBlitzStatisticsPro.WgApiClient.Model;
|
||||
|
||||
namespace WotBlitzStatisticsPro.Logic.Mappers
|
||||
{
|
||||
public class AccountSearchResponseProfile : Profile
|
||||
{
|
||||
public AccountSearchResponseProfile()
|
||||
{
|
||||
CreateMap<WotAccountListResponse, AccountsSearchResponseItem>()
|
||||
.ForMember(
|
||||
d => d.AccountId,
|
||||
o => o.MapFrom(s => s.AccountId.Value));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using AutoMapper;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
using WotBlitzStatisticsPro.WgApiClient.Model;
|
||||
|
||||
namespace WotBlitzStatisticsPro.Logic.Mappers
|
||||
{
|
||||
public class ClanSearchResponseProfile: Profile
|
||||
{
|
||||
public ClanSearchResponseProfile()
|
||||
{
|
||||
CreateMap<WotClanListResponse, ClanSearchResponseItem>()
|
||||
.ForMember(
|
||||
d => d.ClanId,
|
||||
o => o.MapFrom(s => s.ClanId.Value));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
|
||||
namespace WotBlitzStatisticsPro.Logic
|
||||
{
|
||||
public class WargamingDictionaries: IWargamingDictionaries
|
||||
{
|
||||
public Task<UpdateDictionariesResponseItem[]> UpdateDictionaries(UpdateDictionariesRequest updateDictionariesRequest)
|
||||
{
|
||||
var response = new List<UpdateDictionariesResponseItem>();
|
||||
// ToDo: Make factory
|
||||
if ((updateDictionariesRequest.DictionaryTypes & DictionaryType.StaticDictionaries) != 0)
|
||||
{
|
||||
// Update static
|
||||
}
|
||||
if ((updateDictionariesRequest.DictionaryTypes & DictionaryType.Achievements) != 0)
|
||||
{
|
||||
// Update achievements
|
||||
}
|
||||
if ((updateDictionariesRequest.DictionaryTypes & DictionaryType.Vehicles) != 0)
|
||||
{
|
||||
// Update vehicles
|
||||
}
|
||||
|
||||
return Task.FromResult(response.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
using WotBlitzStatisticsPro.WgApiClient;
|
||||
using WotBlitzStatisticsPro.WgApiClient.Model;
|
||||
|
||||
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);
|
||||
return new AccountsSearchResponse
|
||||
{
|
||||
AccountsCount = response.Count,
|
||||
Accounts = _mapper.Map<List<WotAccountListResponse>, List<AccountsSearchResponseItem>>(response)
|
||||
};
|
||||
}
|
||||
|
||||
public async Task<ClanSearchResponse> FindClans(
|
||||
string searchString,
|
||||
RealmType realmType,
|
||||
RequestLanguage language)
|
||||
{
|
||||
var response = await _wargamingApiClient.FindClans(searchString, realmType, language);
|
||||
return new ClanSearchResponse
|
||||
{
|
||||
ClansCount = response.Count,
|
||||
Clans = _mapper.Map<List<WotClanListResponse>, List<ClanSearchResponseItem>>(response)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using WotBlitzStatisticsPro.WgApiClient;
|
||||
|
||||
namespace WotBlitzStatisticsPro.Logic
|
||||
{
|
||||
public static class WotBlitzStatisticsLogicInstaller
|
||||
{
|
||||
public static void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddAutoMapper(typeof(WotBlitzStatisticsLogicInstaller));
|
||||
services.AddHttpClient<IWargamingApiClient, WargamingApiClient>();
|
||||
services.AddTransient<IWargamingSearch, WargamingSearch>();
|
||||
services.AddTransient<IWargamingDictionaries, WargamingDictionaries>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="9.0.0" />
|
||||
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.4" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WotBlitzStatisticsPro.Common\WotBlitzStatisticsPro.Common.csproj" />
|
||||
<ProjectReference Include="..\WotBlitzStatisticsPro.WgApiClient\WotBlitzStatisticsPro.WgApiClient.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in new issue
Block a user