|
|
@ -29,28 +29,27 @@ namespace NzbDrone.Api.QualityProfiles
|
|
|
|
if (request.Id == 0)
|
|
|
|
if (request.Id == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var profiles = _qualityProvider.All();
|
|
|
|
var profiles = _qualityProvider.All();
|
|
|
|
var models = new List<QualityProfileModel>();
|
|
|
|
return Mapper.Map<List<QualityProfile>, List<QualityProfileModel>>(profiles);
|
|
|
|
|
|
|
|
|
|
|
|
profiles.ForEach(p => models.Add(ToModel(p)));
|
|
|
|
|
|
|
|
return models;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var profile = _qualityProvider.Get(request.Id);
|
|
|
|
var profile = _qualityProvider.Get(request.Id);
|
|
|
|
return ToModel(profile);
|
|
|
|
return Mapper.Map<QualityProfile, QualityProfileModel>(profile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override object OnPost(QualityProfileModel data)
|
|
|
|
public override object OnPost(QualityProfileModel data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
//Create
|
|
|
|
var profile = Mapper.Map<QualityProfileModel, QualityProfile>(data);
|
|
|
|
var profile = Mapper.Map<QualityProfileModel, QualityProfile>(data);
|
|
|
|
_qualityProvider.Update(profile);
|
|
|
|
_qualityProvider.Add(profile);
|
|
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override object OnPut(QualityProfileModel data)
|
|
|
|
public override object OnPut(QualityProfileModel data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
//Update
|
|
|
|
var profile = Mapper.Map<QualityProfileModel, QualityProfile>(data);
|
|
|
|
var profile = Mapper.Map<QualityProfileModel, QualityProfile>(data);
|
|
|
|
data.Id = _qualityProvider.Add(profile);
|
|
|
|
_qualityProvider.Update(profile);
|
|
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -61,21 +60,5 @@ namespace NzbDrone.Api.QualityProfiles
|
|
|
|
|
|
|
|
|
|
|
|
return "ok";
|
|
|
|
return "ok";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public QualityProfileModel ToModel(QualityProfile profile)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var model = new QualityProfileModel();
|
|
|
|
|
|
|
|
model.Id = profile.QualityProfileId;
|
|
|
|
|
|
|
|
model.Name = profile.Name;
|
|
|
|
|
|
|
|
model.Cutoff = (int)profile.Cutoff;
|
|
|
|
|
|
|
|
model.Qualities = Mapper.Map<List<QualityTypes>, List<QualityProfileType>>(QualityTypes.All());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model.Qualities.ForEach(quality =>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
quality.Allowed = profile.Allowed.SingleOrDefault(q => q.Id == quality.Id) != null;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return model;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|