session-companion/SessionCompanion/SessionCompanion.Services/Profiles/SpellProfile.cs

35 lines
2.2 KiB
C#
Raw Normal View History

2020-12-27 20:08:19 +01:00
using AutoMapper;
using SessionCompanion.Database.Tables;
using SessionCompanion.ViewModels.SpellViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SessionCompanion.Services.Profiles
{
public class SpellProfile : Profile
{
public SpellProfile()
{
CreateMap<SpellViewModel, Spell>()
.ForMember(model => model.Description, conf => conf.MapFrom(spell => string.Join(";", spell.Descriptions.Select(s => s.ToString()))))
.ForMember(model => model.Components, conf => conf.MapFrom(spell => string.Join(";", spell.Components.Select(s => s.ToString()))))
.ForMember(model => model.HigherLevel, conf => conf.MapFrom(spell => string.Join(";", spell.HigherLevel.Select(s => s.ToString()))))
.ForMember(model => model.Classes, conf => conf.MapFrom(spell => string.Join(";", spell.Classes.Select(s => s.ToString()))))
.ForMember(model => model.Subclasses, conf => conf.MapFrom(spell => string.Join(";", spell.Subclasses.Select(s => s.ToString()))));
CreateMap<Spell, SpellViewModel>()
.ForMember(vm => vm.Range, conf => conf.MapFrom(spell => spell.Range.ToString()))
.ForMember(vm => vm.Duration, conf => conf.MapFrom(spell => spell.Duration.ToString()))
.ForMember(vm => vm.CastingTime, conf => conf.MapFrom(spell => spell.CastingTime.ToString()))
.ForMember(vm => vm.School, conf => conf.MapFrom(spell => spell.School.ToString()))
.ForMember(vm => vm.Descriptions, conf => conf.MapFrom(spell => spell.Description.Split(new char[] { ';' }).ToList()))
.ForMember(vm => vm.Components, conf => conf.MapFrom(spell => spell.Components.Split(new char[] { ';' }).ToList()))
.ForMember(vm => vm.HigherLevel, conf => conf.MapFrom(spell => spell.HigherLevel.Split(new char[] { ';' }).ToList()))
.ForMember(vm => vm.Classes, conf => conf.MapFrom(spell => spell.Classes.Split(new char[] { ';' }).ToList()))
.ForMember(vm => vm.Subclasses, conf => conf.MapFrom(spell => spell.Subclasses.Split(new char[] { ';' }).ToList()));
}
}
}