moving validation rules to restmodule.

This commit is contained in:
kay.one 2013-04-20 13:16:33 -07:00
commit 373a93be64
5 changed files with 10 additions and 33 deletions

View file

@ -6,7 +6,7 @@ using NzbDrone.Api.Extensions;
namespace NzbDrone.Api.REST
{
public abstract class RestModule<TResource> : NancyModule
where TResource : RestResource<TResource>, new()
where TResource : RestResource, new()
{
private const string ROOT_ROUTE = "/";
private const string ID_ROUTE = "/{id}";
@ -54,6 +54,10 @@ namespace NzbDrone.Api.REST
DeleteResource(options.Id);
return new Response { StatusCode = HttpStatusCode.OK };
};
}
protected Action<int> DeleteResource { get; set; }
@ -76,11 +80,11 @@ namespace NzbDrone.Api.REST
if (Request.Method.Equals("POST", StringComparison.InvariantCultureIgnoreCase))
{
resource.ValidateForPost();
//resource.ValidateForPost();
}
else if (Request.Method.Equals("PUT", StringComparison.InvariantCultureIgnoreCase))
{
resource.ValidateForPut();
//resource.ValidateForPut();
}
return resource;