feat: achievements queries added

This commit is contained in:
Mikhail Shabanov committed 2021-03-23 13:44:03 +01:00
1 parent b4e28506ba
commit 310f46b1e7
18 files changed
+505 -45

No files matched your search

@@ -1,23 +0,0 @@
using System.Collections.Generic;
using AutoMapper;
using WotBlitzStatisticsPro.Common.Dictionaries;
using WotBlitzStatisticsPro.DataAccess.Model;
using WotBlitzStatisticsPro.WgApiClient.Model;
namespace WotBlitzStatisticsPro.Logic.Mappers
{
public class AchievementDictionaryProfile : Profile
{
public AchievementDictionaryProfile()
{
CreateMap<WotEncyclopediaAchievementsResponse, AchievementDictionary>()
.ForMember(d => d.Name, o => o.MapFrom(_ => new List<LocalizableString>()))
.ForMember(d => d.Condition, o => o.MapFrom(_ => new List<LocalizableString>()))
.ForMember(d => d.Description, o => o.MapFrom(_ => new List<LocalizableString>()))
.ForMember(d => d.HeroInfo, o => o.MapFrom(_ => new List<LocalizableString>()))
.ForMember(d => d.SectionId, o => o.MapFrom(s => s.Section))
.ForMember(d => d.Options, o => o.Ignore());
}
}
}
@@ -1,17 +0,0 @@
using System.Collections.Generic;
using AutoMapper;
using WotBlitzStatisticsPro.Common.Dictionaries;
using WotBlitzStatisticsPro.WgApiClient.Model;
namespace WotBlitzStatisticsPro.Logic.Mappers
{
public class AchievementOptionProfile : Profile
{
public AchievementOptionProfile()
{
CreateMap<WotEncyclopediaAchievementsOptions, AchievementOption>()
.ForMember(d => d.Name, o => o.MapFrom(_ => new List<LocalizableString>()))
.ForMember(d => d.Description, o => o.MapFrom(_ => new List<LocalizableString>()));
}
}
}
@@ -0,0 +1,60 @@
using System.Collections.Generic;
using System.Linq;
using AutoMapper;
using WotBlitzStatisticsPro.Common.Dictionaries;
using WotBlitzStatisticsPro.Common.Model;
using WotBlitzStatisticsPro.Common.Model.Achievements;
using WotBlitzStatisticsPro.DataAccess.Model;
using WotBlitzStatisticsPro.WgApiClient.Model;
namespace WotBlitzStatisticsPro.Logic.Mappers
{
public class AchievementsProfile: Profile
{
public AchievementsProfile()
{
CreateMap<WotEncyclopediaAchievementsOptions, AchievementOption>()
.ForMember(d => d.Name, o => o.MapFrom(_ => new List<LocalizableString>()))
.ForMember(d => d.Description, o => o.MapFrom(_ => new List<LocalizableString>()));
CreateMap<WotEncyclopediaAchievementsResponse, AchievementDictionary>()
.ForMember(d => d.Name, o => o.MapFrom(_ => new List<LocalizableString>()))
.ForMember(d => d.Condition, o => o.MapFrom(_ => new List<LocalizableString>()))
.ForMember(d => d.Description, o => o.MapFrom(_ => new List<LocalizableString>()))
.ForMember(d => d.HeroInfo, o => o.MapFrom(_ => new List<LocalizableString>()))
.ForMember(d => d.SectionId, o => o.MapFrom(s => s.Section))
.ForMember(d => d.Options, o => o.Ignore());
CreateMap<AchievementSectionDictionary, AchievementSection>()
.ForMember(s => s.SectionId,
o => o.MapFrom(d => d.AchievementSectionId))
.ForMember(d => d.Name,
o => o.MapFrom((src, dest, destMember, context) =>
src.AchievementSectionNames
.FirstOrDefault(l => l.Language == (RequestLanguage) context.Items["language"])?.Value));
CreateMap<KeyValuePair<string, int>, Achievement>()
.ForMember(d => d.Id, o => o.MapFrom(s => s.Key))
.ForMember(d => d.AchievementValue, o => o.MapFrom(s => s.Value));
CreateMap<AchievementDictionary, Achievement>()
.ForMember(d => d.Condition,
o => o.MapFrom((src, dest, destMember, context) =>
src.Condition
.FirstOrDefault(l => l.Language == (RequestLanguage) context.Items["language"])?.Value))
.ForMember(d => d.Description,
o => o.MapFrom((src, dest, destMember, context) =>
src.Description
.FirstOrDefault(l => l.Language == (RequestLanguage) context.Items["language"])?.Value))
.ForMember(d => d.Name,
o => o.MapFrom((src, dest, destMember, context) =>
src.Name
.FirstOrDefault(l => l.Language == (RequestLanguage) context.Items["language"])?.Value))
.ForMember(d => d.Id, o => o.Ignore())
.ForMember(d => d.AchievementValue, o => o.Ignore())
.ForMember(d => d.MaxSeriesValue, s => s.Ignore())
;
}
}
}
@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using AutoMapper;
using WotBlitzStatisticsPro.Common.Dictionaries;
using WotBlitzStatisticsPro.Common.Model;
using WotBlitzStatisticsPro.DataAccess.Model;
using WotBlitzStatisticsPro.WgApiClient.Model;
using WotBlitzStatisticsPro.Logic.Calculations;
@@ -18,7 +15,7 @@ namespace WotBlitzStatisticsPro.Logic.Mappers
CreateMap<ClanAccountInfo, ClanInfoResponse>()
.ForMember(d => d.JoinedAt,
o => o.MapFrom(s => s.JoinedAt.HasValue ? s.JoinedAt.Value.ToDateTime() : new DateTime(1970, 1, 1)))
.ForMember(d => d.Role,
.ForMember(d => d.RoleLocalized,
o => o.MapFrom((src, dest, destMember, context) =>
{
var dictionary = context.Items["roles"] as Dictionary<string, string>;