1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-27 18:28:19 +00:00
Sonarr/NzbDrone.Api/Resolvers/AllowedToQualitiesResolver.cs

25 lines
732 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;
using NzbDrone.Api.QualityProfiles;
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;
}
}
}