2013-02-14 04:56:06 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using AutoMapper;
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Api.Resolvers
|
|
|
|
|
{
|
2013-02-20 03:05:15 +01:00
|
|
|
|
public class NextAiringResolver : ValueResolver<Core.Tv.Series, DateTime?>
|
2013-02-14 04:56:06 +01:00
|
|
|
|
{
|
2013-02-20 03:05:15 +01:00
|
|
|
|
protected override DateTime? ResolveCore(Core.Tv.Series source)
|
2013-02-14 04:56:06 +01:00
|
|
|
|
{
|
2013-02-20 03:05:15 +01:00
|
|
|
|
if (String.IsNullOrWhiteSpace(source.AirTime) || !source.NextAiring.HasValue)
|
2013-02-14 04:56:06 +01:00
|
|
|
|
return source.NextAiring;
|
|
|
|
|
|
|
|
|
|
return source.NextAiring.Value.Add(Convert.ToDateTime(source.AirTime).TimeOfDay)
|
|
|
|
|
.AddHours(source.UtcOffset * -1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|