mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-11 15:56:05 -07:00
More mapping
This commit is contained in:
parent
41f03b46f1
commit
b391861e6e
4 changed files with 43 additions and 19 deletions
|
@ -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
|
namespace Ombi.Mapping
|
||||||
{
|
{
|
||||||
|
@ -6,9 +12,19 @@ namespace Ombi.Mapping
|
||||||
{
|
{
|
||||||
public static IServiceCollection AddOmbiMappingProfile(this IServiceCollection services)
|
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 =>
|
var config = new AutoMapper.MapperConfiguration(cfg =>
|
||||||
{
|
{
|
||||||
cfg.AddProfile(new OmbiProfile());
|
//cfg.AddProfile(new OmbiProfile());
|
||||||
|
cfg.AddProfiles(assemblies);
|
||||||
});
|
});
|
||||||
|
|
||||||
var mapper = config.CreateMapper();
|
var mapper = config.CreateMapper();
|
||||||
|
|
|
@ -1,23 +1,14 @@
|
||||||
using System;
|
using AutoMapper;
|
||||||
using System.Collections.Generic;
|
|
||||||
using AutoMapper;
|
|
||||||
using Ombi.Api.TheMovieDb.Models;
|
using Ombi.Api.TheMovieDb.Models;
|
||||||
using Ombi.Core.Models;
|
|
||||||
using Ombi.Core.Models.Search;
|
using Ombi.Core.Models.Search;
|
||||||
using Ombi.Store.Entities;
|
|
||||||
using Ombi.TheMovieDbApi.Models;
|
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>()
|
CreateMap<SearchResult, MovieSearchResult>()
|
||||||
.ForMember(dest => dest.Adult, opts => opts.MapFrom(src => src.adult))
|
.ForMember(dest => dest.Adult, opts => opts.MapFrom(src => src.adult))
|
||||||
.ForMember(dest => dest.BackdropPath, opts => opts.MapFrom(src => src.backdrop_path))
|
.ForMember(dest => dest.BackdropPath, opts => opts.MapFrom(src => src.backdrop_path))
|
||||||
|
@ -55,7 +46,7 @@ namespace Ombi.Mapping
|
||||||
CreateMap<Genre, GenreDto>();
|
CreateMap<Genre, GenreDto>();
|
||||||
|
|
||||||
CreateMap<MovieSearchResult, SearchMovieViewModel>().ReverseMap();
|
CreateMap<MovieSearchResult, SearchMovieViewModel>().ReverseMap();
|
||||||
|
CreateMap<MovieResponseDto, SearchMovieViewModel>().ReverseMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
17
Ombi/Ombi.Mapping/Profiles/OmbiProfile.cs
Normal file
17
Ombi/Ombi.Mapping/Profiles/OmbiProfile.cs
Normal file
|
@ -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">
|
<nav *ngIf="showNav" class="navbar navbar-default navbar-fixed-top">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue