Files
WotBlitzStatisticsBlazor/WotBlitzStatisticsPro.Logic/Mappers/VehicleDictionaryProfile.cs
T

41 lines
1.8 KiB
C#
Raw Normal View History

2020-12-27 17:20:57 +01:00
using System;
using System.Collections.Generic;
2020-06-07 14:39:03 +02:00
using AutoMapper;
using WotBlitzStatisticsPro.Common.Dictionaries;
2020-06-24 12:19:03 +02:00
using WotBlitzStatisticsPro.DataAccess.Model;
2020-06-07 14:39:03 +02:00
using WotBlitzStatisticsPro.WgApiClient.Model;
namespace WotBlitzStatisticsPro.Logic.Mappers
{
public class VehicleDictionaryProfile : Profile
{
public VehicleDictionaryProfile()
{
CreateMap<WotEncyclopediaVehiclesResponse, VehiclesDictionary>()
.ForMember(d => d.TankId,
o => o.MapFrom(s => s.TankId))
.ForMember(d => d.Name, o => o.MapFrom(_ => new List<LocalizableString>()))
.ForMember(d => d.Description, o => o.MapFrom(_ => new List<LocalizableString>()))
.ForMember(d => d.TypeId,
o => o.MapFrom(s => s.Type))
.ForMember(d => d.NationId,
o => o.MapFrom(s => s.Nation))
.ForMember(d => d.Tier,
o => o.MapFrom(s => s.Tier))
.ForMember(d => d.PreviewImage,
2020-12-27 12:39:25 +01:00
o => o.MapFrom(s => s.Images == null ? string.Empty : s.Images["preview"]))
2020-06-07 14:39:03 +02:00
.ForMember(d => d.NormalImage,
2020-12-27 12:39:25 +01:00
o => o.MapFrom(s => s.Images == null ? string.Empty : s.Images["normal"]))
2020-06-07 14:39:03 +02:00
.ForMember(d => d.PriceCredit,
2020-12-27 17:20:57 +01:00
o => o.MapFrom(s => s.Cost == null ? decimal.Zero : Convert.ToDecimal(s.Cost["price_credit"])))
2020-06-07 14:39:03 +02:00
.ForMember(d => d.PriceGold,
2020-12-27 17:20:57 +01:00
o => o.MapFrom(s => s.Cost == null ? decimal.Zero : Convert.ToDecimal(s.Cost["price_gold"])))
2020-06-07 14:39:03 +02:00
.ForMember(d => d.NexTanksInTree,
o =>
o.MapFrom(s => s.NextTanks))
.ForMember(d => d.PriceXp,
o =>
o.MapFrom(s => s.PricesXp));
}
}
}