Account info step

This commit is contained in:
Mikhail Shabanov committed 2020-08-20 13:40:08 +02:00
1 parent 414a8c188f
commit 50ecb57591
7 files changed
+205 -25

No files matched your search

@@ -0,0 +1,120 @@
namespace WotBlitzStatisticsPro.DataAccess.Model.Accounts
{
public class AccountInfoHistory
{
///<summary>
/// Player account identifier
///</summary>
public long AccountId { get; set; }
///<summary>
/// Last battle time
///</summary>
public int LastBattleTime { get; set; }
///<summary>
/// Battles count
///</summary>
public long? Battles { get; set; }
///<summary>
/// Capture points
///</summary>
public long? CapturePoints { get; set; }
///<summary>
/// Total damage amount
///</summary>
public long? DamageDealt { get; set; }
///<summary>
/// Total amount of received damage
///</summary>
public long? DamageReceived { get; set; }
///<summary>
/// Dropped capture points
///</summary>
public long? DroppedCapturePoints { get; set; }
///<summary>
/// Total amount of frags
///</summary>
public long? Frags { get; set; }
///<summary>
/// Total amount of fras grater ten 8 lvl
///</summary>
public long? Frags8P { get; set; }
///<summary>
/// Total amount of hits
///</summary>
public long? Hits { get; set; }
///<summary>
/// Total amount of losses
///</summary>
public long? Losses { get; set; }
///<summary>
/// Max frags per battle
///</summary>
public long? MaxFrags { get; set; }
///<summary>
/// Tank id, which kills max frags per battle
///</summary>
public long? MaxFragsTankId { get; set; }
///<summary>
/// Max experience per battle
///</summary>
public long? MaxXp { get; set; }
///<summary>
/// Tank Id which created max experiense per battle
///</summary>
public long? MaxXpTankId { get; set; }
///<summary>
/// Total shots count
///</summary>
public long? Shots { get; set; }
///<summary>
/// Total count of spotted vehicles
///</summary>
public long? Spotted { get; set; }
///<summary>
/// Total count of survived battles
///</summary>
public long? SurvivedBattles { get; set; }
///<summary>
/// Total count of suvived and winned battles
///</summary>
public long? WinAndSurvived { get; set; }
///<summary>
/// Total wins count
///</summary>
public long? Wins { get; set; }
///<summary>
/// Total amount of experience
///</summary>
public long? Xp { get; set; }
/// <summary>
/// Average tier
/// </summary>
public double AvgTier { get; set; }
/// <summary>
/// Wn7 coefficient
/// </summary>
public double Wn7 { get; set; }
}
}
@@ -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; }
}
}
@@ -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);
}
}
}
@@ -0,0 +1,14 @@
using AutoMapper;
using WotBlitzStatisticsPro.DataAccess.Model.Accounts;
using WotBlitzStatisticsPro.WgApiClient.Model;
namespace WotBlitzStatisticsPro.Logic.Mappers
{
public class AccountInfoProfile : Profile
{
public AccountInfoProfile()
{
CreateMap<WotAccountInfo, AccountInfo>();
}
}
}
@@ -0,0 +1,14 @@
using AutoMapper;
using WotBlitzStatisticsPro.DataAccess.Model.Accounts;
using WotBlitzStatisticsPro.WgApiClient.Model;
namespace WotBlitzStatisticsPro.Logic.Mappers
{
public class AccountInfoStatisticsProfile : Profile
{
public AccountInfoStatisticsProfile()
{
CreateMap<WotAccountFullStatistics, AccountInfoHistory>();
}
}
}
@@ -8,114 +8,114 @@ namespace WotBlitzStatisticsPro.WgApiClient.Model
/// Battles count
///</summary>
[JsonProperty("battles")]
public long? Battles { get; set; }
public long Battles { get; set; }
///<summary>
/// Capture points
///</summary>
[JsonProperty("capture_points")]
public long? CapturePoints { get; set; }
public long CapturePoints { get; set; }
///<summary>
/// Total damage amount
///</summary>
[JsonProperty("damage_dealt")]
public long? DamageDealt { get; set; }
public long DamageDealt { get; set; }
///<summary>
/// Total amount of received damage
///</summary>
[JsonProperty("damage_received")]
public long? DamageReceived { get; set; }
public long DamageReceived { get; set; }
///<summary>
/// Dropped capture points
///</summary>
[JsonProperty("dropped_capture_points")]
public long? DroppedCapturePoints { get; set; }
public long DroppedCapturePoints { get; set; }
///<summary>
/// Total amount of frags
///</summary>
[JsonProperty("frags")]
public long? Frags { get; set; }
public long Frags { get; set; }
///<summary>
/// Total amount of fras grater ten 8 lvl
///</summary>
[JsonProperty("frags8p")]
public long? Frags8P { get; set; }
public long Frags8P { get; set; }
///<summary>
/// Total amount of hits
///</summary>
[JsonProperty("hits")]
public long? Hits { get; set; }
public long Hits { get; set; }
///<summary>
/// Total amount of losses
///</summary>
[JsonProperty("losses")]
public long? Losses { get; set; }
public long Losses { get; set; }
///<summary>
/// Max frags per battle
///</summary>
[JsonProperty("max_frags")]
public long? MaxFrags { get; set; }
public long MaxFrags { get; set; }
///<summary>
/// Tank id, which kills max frags per battle
///</summary>
[JsonProperty("max_frags_tank_id")]
public long? MaxFragsTankId { get; set; }
public long MaxFragsTankId { get; set; }
///<summary>
/// Max experience per battle
///</summary>
[JsonProperty("max_xp")]
public long? MaxXp { get; set; }
public long MaxXp { get; set; }
///<summary>
/// Tank Id which created max experiense per battle
///</summary>
[JsonProperty("max_xp_tank_id")]
public long? MaxXpTankId { get; set; }
public long MaxXpTankId { get; set; }
///<summary>
/// Total shots count
///</summary>
[JsonProperty("shots")]
public long? Shots { get; set; }
public long Shots { get; set; }
///<summary>
/// Total count of spotted vehicles
///</summary>
[JsonProperty("spotted")]
public long? Spotted { get; set; }
public long Spotted { get; set; }
///<summary>
/// Total count of survived battles
///</summary>
[JsonProperty("survived_battles")]
public long? SurvivedBattles { get; set; }
public long SurvivedBattles { get; set; }
///<summary>
/// Total count of suvived and winned battles
///</summary>
[JsonProperty("win_and_survived")]
public long? WinAndSurvived { get; set; }
public long WinAndSurvived { get; set; }
///<summary>
/// Total wins count
///</summary>
[JsonProperty("wins")]
public long? Wins { get; set; }
public long Wins { get; set; }
///<summary>
/// Total amount of experience
///</summary>
[JsonProperty("xp")]
public long? Xp { get; set; }
public long Xp { get; set; }
}
}
@@ -8,19 +8,19 @@ namespace WotBlitzStatisticsPro.WgApiClient.Model
/// Player account identifier
///</summary>
[JsonProperty("account_id")]
public long? AccountId { get; set; }
public long AccountId { get; set; }
///<summary>
/// Account creation date
///</summary>
[JsonProperty("created_at")]
public int? CreatedAt { get; set; }
public int CreatedAt { get; set; }
///<summary>
/// Last battle time
///</summary>
[JsonProperty("last_battle_time")]
public int? LastBattleTime { get; set; }
public int LastBattleTime { get; set; }
///<summary>
/// Player's nick
@@ -32,7 +32,7 @@ namespace WotBlitzStatisticsPro.WgApiClient.Model
/// Player information update date
///</summary>
[JsonProperty("updated_at")]
public int? UpdatedAt { get; set; }
public int UpdatedAt { get; set; }
///<summary>
/// Private account data