34 lines
2.1 KiB
C#
34 lines
2.1 KiB
C#
|
using AutoMapper;
|
|||
|
using SessionCompanion.Database.Tables;
|
|||
|
using SessionCompanion.ViewModels.CharacterSpellViewModels;
|
|||
|
using System.Linq;
|
|||
|
|
|||
|
namespace SessionCompanion.Services.Profiles
|
|||
|
{
|
|||
|
public class CharacterSpellProfile : Profile
|
|||
|
{
|
|||
|
public CharacterSpellProfile()
|
|||
|
{
|
|||
|
CreateMap<CharacterSpellViewModel, CharacterSpell>().ReverseMap();
|
|||
|
|
|||
|
CreateMap<CharacterSpellWithSpellDetailsViewModel, CharacterSpell>();
|
|||
|
CreateMap<CharacterSpell, CharacterSpellWithSpellDetailsViewModel>()
|
|||
|
|
|||
|
.ForMember(vm => vm.Level, conf => conf.MapFrom(spell => spell.Spell.Level))
|
|||
|
.ForMember(vm => vm.Concentration, conf => conf.MapFrom(spell => spell.Spell.Concentration))
|
|||
|
.ForMember(vm => vm.Ritual, conf => conf.MapFrom(spell => spell.Spell.Ritual))
|
|||
|
.ForMember(vm => vm.Name, conf => conf.MapFrom(spell => spell.Spell.Name.ToString()))
|
|||
|
.ForMember(vm => vm.Material, conf => conf.MapFrom(spell => spell.Spell.Material.ToString()))
|
|||
|
.ForMember(vm => vm.Range, conf => conf.MapFrom(spell => spell.Spell.Range.ToString()))
|
|||
|
.ForMember(vm => vm.Duration, conf => conf.MapFrom(spell => spell.Spell.Duration.ToString()))
|
|||
|
.ForMember(vm => vm.CastingTime, conf => conf.MapFrom(spell => spell.Spell.CastingTime.ToString()))
|
|||
|
.ForMember(vm => vm.School, conf => conf.MapFrom(spell => spell.Spell.School.ToString()))
|
|||
|
.ForMember(vm => vm.Descriptions, conf => conf.MapFrom(spell => spell.Spell.Description.Split(new char[] { ';' }).ToList()))
|
|||
|
.ForMember(vm => vm.Components, conf => conf.MapFrom(spell => spell.Spell.Components.Split(new char[] { ';' }).ToList()))
|
|||
|
.ForMember(vm => vm.HigherLevel, conf => conf.MapFrom(spell => spell.Spell.HigherLevel.Split(new char[] { ';' }).ToList()))
|
|||
|
.ForMember(vm => vm.Classes, conf => conf.MapFrom(spell => spell.Spell.Classes.Split(new char[] { ';' }).ToList()))
|
|||
|
.ForMember(vm => vm.Subclasses, conf => conf.MapFrom(spell => spell.Spell.Subclasses.Split(new char[] { ';' }).ToList()));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|