2013-02-19 01:13:42 +00:00
|
|
|
|
using System;
|
|
|
|
|
using AutoMapper;
|
2013-02-23 17:42:15 +00:00
|
|
|
|
using NzbDrone.Api.Calendar;
|
2013-02-19 01:13:42 +00:00
|
|
|
|
using NzbDrone.Api.QualityProfiles;
|
|
|
|
|
using NzbDrone.Api.QualityType;
|
|
|
|
|
using NzbDrone.Api.Resolvers;
|
|
|
|
|
using NzbDrone.Api.Series;
|
2013-02-20 07:45:52 +00:00
|
|
|
|
using NzbDrone.Api.Upcoming;
|
2013-02-24 20:24:31 +00:00
|
|
|
|
using NzbDrone.Core.Datastore;
|
2013-02-19 01:13:42 +00:00
|
|
|
|
using NzbDrone.Core.Repository.Quality;
|
2013-02-20 07:45:52 +00:00
|
|
|
|
using NzbDrone.Core.Tv;
|
2013-02-19 01:13:42 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Api
|
|
|
|
|
{
|
|
|
|
|
public static class AutomapperBootstraper
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public static void InitializeAutomapper()
|
|
|
|
|
{
|
|
|
|
|
//QualityProfiles
|
|
|
|
|
Mapper.CreateMap<QualityProfile, QualityProfileModel>()
|
|
|
|
|
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.QualityProfileId))
|
|
|
|
|
.ForMember(dest => dest.Qualities,
|
|
|
|
|
opt => opt.ResolveUsing<AllowedToQualitiesResolver>().FromMember(src => src.Allowed));
|
|
|
|
|
|
|
|
|
|
Mapper.CreateMap<QualityProfileModel, QualityProfile>()
|
|
|
|
|
.ForMember(dest => dest.QualityProfileId, opt => opt.MapFrom(src => src.Id))
|
|
|
|
|
.ForMember(dest => dest.Allowed,
|
|
|
|
|
opt => opt.ResolveUsing<QualitiesToAllowedResolver>().FromMember(src => src.Qualities));
|
|
|
|
|
|
|
|
|
|
Mapper.CreateMap<QualityTypes, QualityProfileType>()
|
|
|
|
|
.ForMember(dest => dest.Allowed, opt => opt.Ignore());
|
|
|
|
|
|
|
|
|
|
//QualityTypes
|
|
|
|
|
Mapper.CreateMap<Core.Repository.Quality.QualityType, QualityTypeModel>()
|
|
|
|
|
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.QualityTypeId));
|
|
|
|
|
|
|
|
|
|
Mapper.CreateMap<QualityTypeModel, Core.Repository.Quality.QualityType>()
|
|
|
|
|
.ForMember(dest => dest.QualityTypeId, opt => opt.MapFrom(src => src.Id));
|
|
|
|
|
|
|
|
|
|
//Series
|
2013-02-19 07:20:51 +00:00
|
|
|
|
Mapper.CreateMap<Core.Tv.Series, SeriesResource>()
|
2013-02-26 03:58:57 +00:00
|
|
|
|
.ForMember(dest => dest.Id, opt => opt.MapFrom(src => src.Id))
|
2013-02-19 01:13:42 +00:00
|
|
|
|
.ForMember(dest => dest.CustomStartDate, opt => opt.ResolveUsing<NullableDatetimeToString>().FromMember(src => src.CustomStartDate))
|
|
|
|
|
.ForMember(dest => dest.BacklogSetting, opt => opt.MapFrom(src => (Int32)src.BacklogSetting))
|
|
|
|
|
.ForMember(dest => dest.NextAiring, opt => opt.ResolveUsing<NextAiringResolver>());
|
2013-02-20 07:45:52 +00:00
|
|
|
|
|
|
|
|
|
//Upcoming
|
|
|
|
|
Mapper.CreateMap<Episode, UpcomingResource>()
|
|
|
|
|
.ForMember(dest => dest.SeriesTitle, opt => opt.MapFrom(src => src.Series.Title))
|
2013-02-25 00:00:17 +00:00
|
|
|
|
.ForMember(dest => dest.EpisodeTitle, opt => opt.MapFrom(src => src.Title));
|
2013-02-23 17:42:15 +00: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 00:00:17 +00:00
|
|
|
|
.ForMember(dest => dest.Start, opt => opt.MapFrom(src => src.AirDate))
|
|
|
|
|
.ForMember(dest => dest.End, opt => opt.ResolveUsing<EndTimeResolver>());
|
2013-02-19 01:13:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|