using System; 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; } public async Task GatherAccountInformation(RealmType realm, long accountId, RequestLanguage requestLanguage) { var context = new AccountInformationPipelineContext(accountId, realm, requestLanguage); var pipeline = new Pipeline(_operationFactory); pipeline.AddOperation() .AddOperation() .AddOperation() .AddOperation() ; await pipeline.Build() .Invoke(context, null) .ConfigureAwait(false); return context.Response; } public async Task GatherAndSaveAccountInformation(RealmType realm, long accountId, RequestLanguage requestLanguage) { var context = new AccountInformationPipelineContext(accountId, realm, requestLanguage); var pipeline = new Pipeline(_operationFactory); pipeline.AddOperation() .AddOperation() .AddOperation() .AddOperation() .AddOperation() .AddOperation() .AddOperation() ; await pipeline.Build() .Invoke(context, null) .ConfigureAwait(false); return context.Response; } public async Task GetAccountInfoHistory(RealmType realm, long accountId, DateTime startDate, RequestLanguage requestLanguage) { var context = new HistoryInformationPipelineContext(accountId, realm, requestLanguage); var pipeline = new Pipeline(_operationFactory); //pipeline.AddOperation() // ToDo: // 1. First read account info from DB operation // 2. Read account history from DB at the startDate !Array SortedByDate! operation // 3. Fill the OverallAccountStatistics // PeriodAccountStatistics // PeriodDifference // StatisticsHistory await pipeline.Build() .Invoke(context, null) .ConfigureAwait(false); return context.Response; } } }