Radarr/NzbDrone.Api/Resolvers/AllowedToQualitiesResolver.cs

25 lines
726 B
C#
Raw Normal View History

2012-12-03 03:08:26 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using AutoMapper;
2013-05-20 00:30:02 +00:00
using NzbDrone.Api.Qualities;
2013-02-27 03:19:22 +00:00
using NzbDrone.Core.Qualities;
2012-12-03 03:08:26 +00:00
namespace NzbDrone.Api.Resolvers
{
2013-02-27 03:19:22 +00:00
public class AllowedToQualitiesResolver : ValueResolver<List<Quality>, List<QualityProfileType>>
2012-12-03 03:08:26 +00:00
{
2013-02-27 03:19:22 +00:00
protected override List<QualityProfileType> ResolveCore(List<Quality> source)
2012-12-03 03:08:26 +00:00
{
2013-02-27 03:19:22 +00:00
var qualities = Mapper.Map<List<Quality>, List<QualityProfileType>>(Quality.All().Where(q => q.Id > 0).ToList());
2012-12-03 03:08:26 +00:00
qualities.ForEach(quality =>
{
quality.Allowed = source.SingleOrDefault(q => q.Id == quality.Id) != null;
});
return qualities;
}
}
}