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() .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() .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())); } } }