Files

23 lines
1.0 KiB
C#
Raw Permalink Normal View History

2020-12-23 16:34:12 +01:00
using AutoMapper;
using WotBlitzStatisticsPro.Common.Model;
using WotBlitzStatisticsPro.Logic.Calculations;
namespace WotBlitzStatisticsPro.Logic.Mappers
{
public class ShortStatisticsProfile: Profile
{
public ShortStatisticsProfile()
{
CreateMap<IStatistics, ShortStatistics>()
.ForMember(d => d.LastBattleTime,
o => o.MapFrom(s => s.LastBattleTime.ToDateTime()))
.ForMember(d => d.AvgDamage,
2020-12-27 12:39:25 +01:00
o => o.MapFrom(s => s.Battles.HasValue && s.DamageDealt.HasValue && s.Battles > 0 ? ((decimal)s.DamageDealt / s.Battles) : 0m))
2020-12-23 16:34:12 +01:00
.ForMember(d => d.AvgXp,
2020-12-27 12:39:25 +01:00
o => o.MapFrom(s => s.Battles.HasValue && s.Xp.HasValue && s.Battles > 0 ? ((decimal)s.Xp / s.Battles) : 0m))
2020-12-23 16:34:12 +01:00
.ForMember(d => d.WinRate,
2020-12-27 12:39:25 +01:00
o => o.MapFrom(s => s.Battles.HasValue && s.Wins.HasValue && s.Battles > 0 ? (100 * (decimal)s.Wins / s.Battles) : 0m))
2020-12-23 16:34:12 +01:00
;
}
}
}