mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-16 10:03:51 -07:00
Updated restmodule, moved series, root folder to the new restmodule.
This commit is contained in:
parent
4878556e14
commit
a2e84a8f83
16 changed files with 321 additions and 219 deletions
|
@ -1,10 +1,20 @@
|
|||
using NzbDrone.Api.REST;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NzbDrone.Api.REST;
|
||||
using NzbDrone.Api.Validation;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using NzbDrone.Api.Mapping;
|
||||
|
||||
namespace NzbDrone.Api
|
||||
{
|
||||
public abstract class NzbDroneRestModule<TResource> : RestModule<TResource> where TResource : RestResource, new()
|
||||
{
|
||||
protected NzbDroneRestModule()
|
||||
: this(new TResource().ResourceName)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected NzbDroneRestModule(string resource)
|
||||
: base("/api/" + resource.Trim('/'))
|
||||
{
|
||||
|
@ -12,5 +22,25 @@ namespace NzbDrone.Api
|
|||
PutValidator.RuleFor(r => r.Id).ValidId();
|
||||
}
|
||||
|
||||
|
||||
protected TResource Apply<TModel>(Func<TModel, TModel> function, TResource resource) where TModel : ModelBase, new()
|
||||
{
|
||||
var model = resource.InjectTo<TModel>();
|
||||
function(model);
|
||||
return model.InjectTo<TResource>();
|
||||
}
|
||||
|
||||
protected List<TResource> Apply<TModel>(Func<IEnumerable<TModel>> function) where TModel : ModelBase, new()
|
||||
{
|
||||
var modelList = function();
|
||||
return modelList.InjectTo<List<TResource>>();
|
||||
}
|
||||
|
||||
protected TResource Apply<TModel>(Func<int, TModel> action, int id) where TModel : ModelBase, new()
|
||||
{
|
||||
var model = action(id);
|
||||
return model.InjectTo<TResource>();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue