2020-05-18 17:29:54 +02:00
|
|
|
using AutoMapper;
|
|
|
|
|
using WotBlitzStatisticsPro.Common.Model;
|
|
|
|
|
using WotBlitzStatisticsPro.WgApiClient.Model;
|
2021-05-12 16:30:23 +02:00
|
|
|
using WotBlitzStatisticsPro.Logic.Calculations;
|
2020-05-18 17:29:54 +02:00
|
|
|
|
2020-05-23 11:43:14 +02:00
|
|
|
namespace WotBlitzStatisticsPro.Logic.Mappers
|
2020-05-18 17:29:54 +02:00
|
|
|
{
|
|
|
|
|
public class AccountSearchResponseProfile : Profile
|
|
|
|
|
{
|
|
|
|
|
public AccountSearchResponseProfile()
|
|
|
|
|
{
|
|
|
|
|
CreateMap<WotAccountListResponse, AccountsSearchResponseItem>()
|
|
|
|
|
.ForMember(
|
|
|
|
|
d => d.AccountId,
|
2020-12-27 12:39:25 +01:00
|
|
|
o => o.MapFrom(s => s.AccountId ?? -1));
|
2021-05-12 16:30:23 +02:00
|
|
|
|
|
|
|
|
CreateMap<WotAccountInfo, AccountsSearchResponseItem>()
|
|
|
|
|
.ForMember(dest => dest.LastBattle,
|
|
|
|
|
o => o.MapFrom(s => s.LastBattleTime.ToDateTime()))
|
|
|
|
|
.ForMember(dest => dest.BattlesCount,
|
|
|
|
|
o => o.MapFrom(s => s.Statistics!.All!.Battles))
|
|
|
|
|
.ForMember(dest => dest.WinRate,
|
|
|
|
|
o => o.MapFrom(s => s.Statistics!.All!.Battles == 0 ? 0 : 100 * s.Statistics!.All!.Wins / s.Statistics!.All!.Battles))
|
|
|
|
|
;
|
2020-05-18 17:29:54 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|