mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
Fixed: Quality Definitions Don't Allow Save
This commit is contained in:
parent
066bf1220f
commit
33d012cfc0
@ -11,6 +11,7 @@ namespace NzbDrone.Core.Qualities
|
||||
public interface IQualityDefinitionService
|
||||
{
|
||||
void Update(QualityDefinition qualityDefinition);
|
||||
void UpdateMany(List<QualityDefinition> qualityDefinitions);
|
||||
List<QualityDefinition> All();
|
||||
QualityDefinition GetById(int id);
|
||||
QualityDefinition Get(Quality quality);
|
||||
@ -41,6 +42,11 @@ public void Update(QualityDefinition qualityDefinition)
|
||||
_cache.Clear();
|
||||
}
|
||||
|
||||
public void UpdateMany(List<QualityDefinition> qualityDefinitions)
|
||||
{
|
||||
_repo.UpdateMany(qualityDefinitions);
|
||||
}
|
||||
|
||||
public List<QualityDefinition> All()
|
||||
{
|
||||
return GetAll().Values.OrderBy(d => d.Weight).ToList();
|
||||
|
@ -1,35 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Radarr.Http.REST;
|
||||
using NzbDrone.Core.Parser;
|
||||
using NzbDrone.Core.Parser.Model;
|
||||
using System.Linq;
|
||||
using Nancy;
|
||||
using NzbDrone.Core.Qualities;
|
||||
using Radarr.Http;
|
||||
using Radarr.Http.Extensions;
|
||||
|
||||
namespace Radarr.Api.V2.Qualities
|
||||
{
|
||||
public class QualityDefinitionModule : RadarrRestModule<QualityDefinitionResource>
|
||||
{
|
||||
private readonly IQualityDefinitionService _qualityDefinitionService;
|
||||
private readonly IParsingService _parsingService;
|
||||
|
||||
public QualityDefinitionModule(IQualityDefinitionService qualityDefinitionService, IParsingService parsingService)
|
||||
public QualityDefinitionModule(IQualityDefinitionService qualityDefinitionService)
|
||||
{
|
||||
_qualityDefinitionService = qualityDefinitionService;
|
||||
_parsingService = parsingService;
|
||||
|
||||
GetResourceAll = GetAll;
|
||||
|
||||
GetResourceById = GetById;
|
||||
|
||||
UpdateResource = Update;
|
||||
|
||||
CreateResource = Create;
|
||||
}
|
||||
|
||||
private int Create(QualityDefinitionResource qualityDefinitionResource)
|
||||
{
|
||||
throw new BadRequestException("Not allowed!");
|
||||
Put("/update", d => UpdateMany());
|
||||
}
|
||||
|
||||
private void Update(QualityDefinitionResource resource)
|
||||
@ -47,5 +36,19 @@ private List<QualityDefinitionResource> GetAll()
|
||||
{
|
||||
return _qualityDefinitionService.All().ToResource();
|
||||
}
|
||||
|
||||
private object UpdateMany()
|
||||
{
|
||||
//Read from request
|
||||
var qualityDefinitions = Request.Body.FromJson<List<QualityDefinitionResource>>()
|
||||
.ToModel()
|
||||
.ToList();
|
||||
|
||||
_qualityDefinitionService.UpdateMany(qualityDefinitions);
|
||||
|
||||
return ResponseWithCode(_qualityDefinitionService.All()
|
||||
.ToResource()
|
||||
, HttpStatusCode.Accepted);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -61,5 +61,10 @@ public static List<QualityDefinitionResource> ToResource(this IEnumerable<Qualit
|
||||
{
|
||||
return models.Select(ToResource).ToList();
|
||||
}
|
||||
|
||||
public static List<QualityDefinition> ToModel(this IEnumerable<QualityDefinitionResource> resources)
|
||||
{
|
||||
return resources.Select(ToModel).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user