예제 #1
0
        public static QualityProfileQualityItem ToModel(this QualityProfileQualityItemResource resource)
        {
            if (resource == null)
            {
                return(null);
            }

            return(new QualityProfileQualityItem
            {
                Id = resource.Id,
                Name = resource.Name,
                Quality = resource.Quality != null ? (NzbDrone.Core.Qualities.Quality)resource.Quality.Id : null,
                Items = resource.Items.ConvertAll(ToModel),
                Allowed = resource.Allowed
            });
        }
예제 #2
0
        protected override bool IsValid(PropertyValidatorContext context)
        {
            int     cutoff   = (int)context.PropertyValue;
            dynamic instance = context.ParentContext.InstanceToValidate;
            var     items    = instance.Items as IList <QualityProfileQualityItemResource>;

            QualityProfileQualityItemResource cutoffItem = items.SingleOrDefault(i => (i.Quality == null && i.Id == cutoff) || i.Quality?.Id == cutoff);

            if (cutoffItem == null)
            {
                return(false);
            }

            if (!cutoffItem.Allowed)
            {
                return(false);
            }

            return(true);
        }