mirror of
https://github.com/DrMboga/WotBlitzStatisticsBlazor.git
synced 2026-10-23 19:30:06 +02:00
Account info step
This commit is contained in:
1 parent
414a8c188f
commit
50ecb57591
7 files changed
+205
-25
No files matched your search
+5
@@ -1,4 +1,5 @@
|
||||
using WotBlitzStatisticsPro.Common.Model;
|
||||
using WotBlitzStatisticsPro.DataAccess.Model.Accounts;
|
||||
|
||||
namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline
|
||||
{
|
||||
@@ -19,5 +20,9 @@ namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline
|
||||
public RealmType RealmType { get; }
|
||||
public RequestLanguage RequestLanguage { get; }
|
||||
|
||||
public AccountInfo AccountInfo { get; set; }
|
||||
|
||||
public AccountInfoHistory AccountInfoHistory { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
+29
-2
@@ -1,14 +1,41 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using AutoMapper;
|
||||
using WotBlitzStatisticsPro.DataAccess.Model.Accounts;
|
||||
using WotBlitzStatisticsPro.Logic.Pipeline;
|
||||
using WotBlitzStatisticsPro.WgApiClient;
|
||||
using WotBlitzStatisticsPro.WgApiClient.Model;
|
||||
|
||||
namespace WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations
|
||||
{
|
||||
public class GetAccountInfoOperation: IOperation<AccountInformationPipelineContext>
|
||||
{
|
||||
public Task Invoke(AccountInformationPipelineContext context, Func<AccountInformationPipelineContext, Task> next)
|
||||
private readonly IWargamingApiClient _wargamingApi;
|
||||
private readonly IMapper _mapper;
|
||||
|
||||
public GetAccountInfoOperation(
|
||||
IWargamingApiClient wargamingApi,
|
||||
IMapper mapper)
|
||||
{
|
||||
return next.Invoke(context);
|
||||
_wargamingApi = wargamingApi;
|
||||
_mapper = mapper;
|
||||
}
|
||||
|
||||
public async Task Invoke(AccountInformationPipelineContext context, Func<AccountInformationPipelineContext, Task> next)
|
||||
{
|
||||
var accountInfo = await
|
||||
_wargamingApi.GetPlayerAccountInfo(context.AccountId, context.RealmType, context.RequestLanguage);
|
||||
|
||||
// Store info to AccountInfo and in AccountInfoHistory
|
||||
context.AccountInfo = _mapper.Map<WotAccountInfo, AccountInfo>(accountInfo);
|
||||
context.AccountInfo.Realm = context.RealmType;
|
||||
|
||||
context.AccountInfoHistory =
|
||||
_mapper.Map<WotAccountFullStatistics, AccountInfoHistory>(accountInfo.Statistics.All);
|
||||
context.AccountInfoHistory.AccountId = context.AccountId;
|
||||
context.AccountInfoHistory.LastBattleTime = context.AccountInfo.LastBattleTime;
|
||||
|
||||
await next.Invoke(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user