More mapping

pull/1425/head
Jamie.Rees 8 years ago
parent 41f03b46f1
commit b391861e6e

@ -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<Type>();
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();

@ -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<User, UserDto>().ReverseMap();
CreateMap<string, DateTime>().ConvertUsing<StringToDateTimeConverter>();
CreateMap<SearchResult, MovieSearchResult>()
.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<MovieResponse, MovieResponseDto>()
.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<Genre, GenreDto>();
CreateMap<MovieSearchResult, SearchMovieViewModel>().ReverseMap();
CreateMap<MovieResponseDto, SearchMovieViewModel>().ReverseMap();
}
}
}
}

@ -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<User, UserDto>().ReverseMap();
CreateMap<string, DateTime>().ConvertUsing<StringToDateTimeConverter>();
}
}
}

@ -1,4 +1,4 @@
<p-growl [value]="notificationService.messages" [life]="500000"></p-growl>
<p-growl [value]="notificationService.messages" [life]="1000"></p-growl>
<nav *ngIf="showNav" class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">

Loading…
Cancel
Save