2013-02-19 02:13:42 +01:00
|
|
|
|
using System;
|
|
|
|
|
using AutoMapper;
|
2013-02-23 18:42:15 +01:00
|
|
|
|
using NzbDrone.Api.Calendar;
|
2013-03-02 20:13:23 +01:00
|
|
|
|
using NzbDrone.Api.Episodes;
|
2013-02-19 02:13:42 +01:00
|
|
|
|
using NzbDrone.Api.QualityProfiles;
|
|
|
|
|
using NzbDrone.Api.QualityType;
|
|
|
|
|
using NzbDrone.Api.Resolvers;
|
|
|
|
|
using NzbDrone.Api.Series;
|
2013-02-27 04:19:22 +01:00
|
|
|
|
using NzbDrone.Core.Qualities;
|
2013-02-20 08:45:52 +01:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2013-02-19 02:13:42 +01:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Api
|
|
|
|
|
{
|
|
|
|
|
public static class AutomapperBootstraper
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public static void InitializeAutomapper()
|
|
|
|
|
{
|
|
|
|
|
//QualityProfiles
|
|
|
|
|
Mapper.CreateMap<QualityProfile, QualityProfileModel>()
|
|
|
|
|
.ForMember(dest => dest.Qualities,
|
|
|
|
|
opt => opt.ResolveUsing<AllowedToQualitiesResolver>().FromMember(src => src.Allowed));
|
|
|
|
|
|
|
|
|
|
Mapper.CreateMap<QualityProfileModel, QualityProfile>()
|
|
|
|
|
.ForMember(dest => dest.Allowed,
|
|
|
|
|
opt => opt.ResolveUsing<QualitiesToAllowedResolver>().FromMember(src => src.Qualities));
|
|
|
|
|
|
2013-02-27 04:19:22 +01:00
|
|
|
|
Mapper.CreateMap<Quality, QualityProfileType>()
|
2013-02-19 02:13:42 +01:00
|
|
|
|
.ForMember(dest => dest.Allowed, opt => opt.Ignore());
|
|
|
|
|
|
2013-02-27 04:19:22 +01:00
|
|
|
|
//QualitySize
|
|
|
|
|
Mapper.CreateMap<QualitySize, QualityTypeModel>()
|
|
|
|
|
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.QualityId));
|
2013-02-19 02:13:42 +01:00
|
|
|
|
|
2013-02-27 04:19:22 +01:00
|
|
|
|
Mapper.CreateMap<QualityTypeModel, QualitySize>()
|
|
|
|
|
.ForMember(dest => dest.QualityId, opt => opt.MapFrom(src => src.Id));
|
2013-02-19 02:13:42 +01:00
|
|
|
|
|
|
|
|
|
//Series
|
2013-02-19 08:20:51 +01:00
|
|
|
|
Mapper.CreateMap<Core.Tv.Series, SeriesResource>()
|
2013-02-26 04:58:57 +01:00
|
|
|
|
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
|
2013-02-19 02:13:42 +01:00
|
|
|
|
.ForMember(dest => dest.CustomStartDate, opt => opt.ResolveUsing<NullableDatetimeToString>().FromMember(src => src.CustomStartDate))
|
|
|
|
|
.ForMember(dest => dest.BacklogSetting, opt => opt.MapFrom(src => (Int32)src.BacklogSetting))
|
2013-03-01 05:59:06 +01:00
|
|
|
|
.ForMember(dest => dest.NextAiring, opt => opt.ResolveUsing<NextAiringResolver>())
|
|
|
|
|
.ForMember(dest => dest.QualityProfileName, opt => opt.MapFrom(src => src.QualityProfile.Name));
|
2013-02-20 08:45:52 +01:00
|
|
|
|
|
2013-02-23 18:42:15 +01:00
|
|
|
|
//Calendar
|
|
|
|
|
Mapper.CreateMap<Episode, CalendarResource>()
|
|
|
|
|
.ForMember(dest => dest.SeriesTitle, opt => opt.MapFrom(src => src.Series.Title))
|
|
|
|
|
.ForMember(dest => dest.EpisodeTitle, opt => opt.MapFrom(src => src.Title))
|
2013-02-25 01:00:17 +01:00
|
|
|
|
.ForMember(dest => dest.Start, opt => opt.MapFrom(src => src.AirDate))
|
|
|
|
|
.ForMember(dest => dest.End, opt => opt.ResolveUsing<EndTimeResolver>());
|
2013-03-02 20:13:23 +01:00
|
|
|
|
|
|
|
|
|
//Episode
|
|
|
|
|
Mapper.CreateMap<Episode, EpisodeResource>();
|
2013-02-19 02:13:42 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|