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