2012-12-03 04:08:26 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using AutoMapper;
|
|
|
|
|
using NzbDrone.Api.QualityProfiles;
|
2013-02-27 04:19:22 +01:00
|
|
|
|
using NzbDrone.Core.Qualities;
|
2012-12-03 04:08:26 +01:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Api.Resolvers
|
|
|
|
|
{
|
2013-02-27 04:19:22 +01:00
|
|
|
|
public class QualitiesToAllowedResolver : ValueResolver<List<QualityProfileType>, List<Quality>>
|
2012-12-03 04:08:26 +01:00
|
|
|
|
{
|
2013-02-27 04:19:22 +01:00
|
|
|
|
protected override List<Quality> ResolveCore(List<QualityProfileType> source)
|
2012-12-03 04:08:26 +01:00
|
|
|
|
{
|
|
|
|
|
var ids = source.Where(s => s.Allowed).Select(s => s.Id).ToList();
|
|
|
|
|
|
2013-02-27 04:19:22 +01:00
|
|
|
|
var qualityTypes = new List<Quality>();
|
2012-12-03 04:08:26 +01:00
|
|
|
|
|
|
|
|
|
ids.ForEach(id =>
|
|
|
|
|
{
|
2013-02-27 04:19:22 +01:00
|
|
|
|
qualityTypes.Add(Quality.FindById(id));
|
2012-12-03 04:08:26 +01:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return qualityTypes;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|