diff --git a/Ombi/Ombi.Mapping/AutoMapperProfile.cs b/Ombi/Ombi.Mapping/AutoMapperProfile.cs index 5b3423389..b8e2ca60b 100644 --- a/Ombi/Ombi.Mapping/AutoMapperProfile.cs +++ b/Ombi/Ombi.Mapping/AutoMapperProfile.cs @@ -1,4 +1,10 @@ -using Microsoft.Extensions.DependencyInjection; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using AutoMapper; +using AutoMapper.Configuration; +using Microsoft.Extensions.DependencyInjection; namespace Ombi.Mapping { @@ -6,9 +12,19 @@ namespace Ombi.Mapping { public static IServiceCollection AddOmbiMappingProfile(this IServiceCollection services) { + System.Reflection.Assembly ass = typeof(AutoMapperProfile).GetTypeInfo().Assembly; + var assemblies = new List(); + foreach (System.Reflection.TypeInfo ti in ass.DefinedTypes) + { + if (ti.ImplementedInterfaces.Contains(typeof(IProfileConfiguration))) + { + assemblies.Add(ti.AsType()); + } + } var config = new AutoMapper.MapperConfiguration(cfg => { - cfg.AddProfile(new OmbiProfile()); + //cfg.AddProfile(new OmbiProfile()); + cfg.AddProfiles(assemblies); }); var mapper = config.CreateMapper(); diff --git a/Ombi/Ombi.Mapping/OmbiProfile.cs b/Ombi/Ombi.Mapping/Profiles/MovieProfile.cs similarity index 89% rename from Ombi/Ombi.Mapping/OmbiProfile.cs rename to Ombi/Ombi.Mapping/Profiles/MovieProfile.cs index 0b493dc03..29b2f3da2 100644 --- a/Ombi/Ombi.Mapping/OmbiProfile.cs +++ b/Ombi/Ombi.Mapping/Profiles/MovieProfile.cs @@ -1,23 +1,14 @@ -using System; -using System.Collections.Generic; -using AutoMapper; +using AutoMapper; using Ombi.Api.TheMovieDb.Models; -using Ombi.Core.Models; using Ombi.Core.Models.Search; -using Ombi.Store.Entities; using Ombi.TheMovieDbApi.Models; -namespace Ombi.Mapping +namespace Ombi.Mapping.Profiles { - public class OmbiProfile : Profile + public class MovieProfile : Profile { - public OmbiProfile() + public MovieProfile() { - - CreateMap().ReverseMap(); - - CreateMap().ConvertUsing(); - CreateMap() .ForMember(dest => dest.Adult, opts => opts.MapFrom(src => src.adult)) .ForMember(dest => dest.BackdropPath, opts => opts.MapFrom(src => src.backdrop_path)) @@ -32,7 +23,7 @@ namespace Ombi.Mapping .ForMember(dest => dest.Video, opts => opts.MapFrom(src => src.video)) .ForMember(dest => dest.VoteAverage, opts => opts.MapFrom(src => src.vote_average)) .ForMember(dest => dest.VoteCount, opts => opts.MapFrom(src => src.vote_count)); - + CreateMap() .ForMember(dest => dest.Adult, opts => opts.MapFrom(src => src.adult)) .ForMember(dest => dest.BackdropPath, opts => opts.MapFrom(src => src.backdrop_path)) @@ -55,7 +46,7 @@ namespace Ombi.Mapping CreateMap(); CreateMap().ReverseMap(); - + CreateMap().ReverseMap(); } } -} +} \ No newline at end of file diff --git a/Ombi/Ombi.Mapping/Profiles/OmbiProfile.cs b/Ombi/Ombi.Mapping/Profiles/OmbiProfile.cs new file mode 100644 index 000000000..272972be6 --- /dev/null +++ b/Ombi/Ombi.Mapping/Profiles/OmbiProfile.cs @@ -0,0 +1,17 @@ +using System; +using AutoMapper; +using Ombi.Core.Models; +using Ombi.Store.Entities; + +namespace Ombi.Mapping.Profiles +{ + public class OmbiProfile : Profile + { + public OmbiProfile() + { + CreateMap().ReverseMap(); + + CreateMap().ConvertUsing(); + } + } +} diff --git a/Ombi/Ombi/wwwroot/app/app.component.html b/Ombi/Ombi/wwwroot/app/app.component.html index f065cfa34..20e7089a0 100644 --- a/Ombi/Ombi/wwwroot/app/app.component.html +++ b/Ombi/Ombi/wwwroot/app/app.component.html @@ -1,4 +1,4 @@ - +