2020-07-19 13:04:31 +02:00
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using WotBlitzStatisticsPro.Common.Model;
|
|
|
|
|
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline;
|
|
|
|
|
using WotBlitzStatisticsPro.Logic.AccountInformationPipeline.Operations;
|
|
|
|
|
using WotBlitzStatisticsPro.Logic.Pipeline;
|
|
|
|
|
|
|
|
|
|
namespace WotBlitzStatisticsPro.Logic
|
|
|
|
|
{
|
|
|
|
|
public class WargamingAccounts: IWargamingAccounts
|
|
|
|
|
{
|
|
|
|
|
private readonly IOperationFactory _operationFactory;
|
|
|
|
|
|
|
|
|
|
public WargamingAccounts(IOperationFactory operationFactory)
|
|
|
|
|
{
|
|
|
|
|
_operationFactory = operationFactory;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-30 19:30:36 +02:00
|
|
|
public async Task<AccountInfoResponse> GatherAccountInformation(RealmType realm, long accountId, RequestLanguage requestLanguage)
|
2020-07-19 13:04:31 +02:00
|
|
|
{
|
|
|
|
|
var context = new AccountInformationPipelineContext(accountId, realm, requestLanguage);
|
|
|
|
|
var pipeline = new Pipeline<AccountInformationPipelineContext>(_operationFactory);
|
|
|
|
|
|
|
|
|
|
pipeline.AddOperation<GetAccountInfoOperation>()
|
|
|
|
|
.AddOperation<GetTanksInfoOperation>()
|
2020-09-22 17:54:35 +02:00
|
|
|
.AddOperation<CalculateStatisticsOperation>()
|
2020-09-30 19:30:36 +02:00
|
|
|
.AddOperation<BuildAccountInfoResponseOperation>()
|
2020-07-19 13:04:31 +02:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
await pipeline.Build()
|
|
|
|
|
.Invoke(context, null)
|
|
|
|
|
.ConfigureAwait(false);
|
|
|
|
|
|
2020-10-25 19:05:08 +01:00
|
|
|
return context.Response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<AccountInfoResponse> GatherAndSaveAccountInformation(RealmType realm, long accountId, RequestLanguage requestLanguage)
|
|
|
|
|
{
|
|
|
|
|
var context = new AccountInformationPipelineContext(accountId, realm, requestLanguage);
|
|
|
|
|
var pipeline = new Pipeline<AccountInformationPipelineContext>(_operationFactory);
|
|
|
|
|
|
|
|
|
|
pipeline.AddOperation<GetAccountInfoOperation>()
|
|
|
|
|
// ToDo: add operation for reading AccountFrom DB
|
|
|
|
|
.AddOperation<GetTanksInfoOperation>()
|
|
|
|
|
.AddOperation<CalculateStatisticsOperation>()
|
|
|
|
|
// ToDo: add operation for save info into DB
|
|
|
|
|
.AddOperation<BuildAccountInfoResponseOperation>()
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
await pipeline.Build()
|
|
|
|
|
.Invoke(context, null)
|
|
|
|
|
.ConfigureAwait(false);
|
2020-07-19 13:04:31 +02:00
|
|
|
|
2020-09-30 19:30:36 +02:00
|
|
|
return context.Response;
|
2020-07-19 13:04:31 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|