|
|
@ -1,11 +1,10 @@
|
|
|
|
using System;
|
|
|
|
using System.IO;
|
|
|
|
using System.IO;
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
using Nancy;
|
|
|
|
using Nancy;
|
|
|
|
using Nancy.Responses;
|
|
|
|
using Nancy.Responses;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Api.QualityType
|
|
|
|
namespace NzbDrone.Api.Extentions
|
|
|
|
{
|
|
|
|
{
|
|
|
|
public static class JsonExtensions
|
|
|
|
public static class JsonExtensions
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -14,17 +13,12 @@ namespace NzbDrone.Api.QualityType
|
|
|
|
var reader = new StreamReader(body, true);
|
|
|
|
var reader = new StreamReader(body, true);
|
|
|
|
body.Position = 0;
|
|
|
|
body.Position = 0;
|
|
|
|
var value = reader.ReadToEnd();
|
|
|
|
var value = reader.ReadToEnd();
|
|
|
|
return JsonConvert.DeserializeObject<T>(value, new JsonSerializerSettings
|
|
|
|
return JsonConvert.DeserializeObject<T>(value, Serializer.Settings);
|
|
|
|
{
|
|
|
|
|
|
|
|
NullValueHandling = NullValueHandling.Ignore,
|
|
|
|
|
|
|
|
MissingMemberHandling = MissingMemberHandling.Ignore
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static JsonResponse<TModel> AsResponse<TModel>(this TModel model, HttpStatusCode statusCode = HttpStatusCode.OK)
|
|
|
|
public static JsonResponse<TModel> AsResponse<TModel>(this TModel model, HttpStatusCode statusCode = HttpStatusCode.OK)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ISerializer serializer = new DefaultJsonSerializer();
|
|
|
|
var jsonResponse = new JsonResponse<TModel>(model, new NancyJsonSerializer()) { StatusCode = statusCode };
|
|
|
|
var jsonResponse = new JsonResponse<TModel>(model, serializer) { StatusCode = statusCode };
|
|
|
|
|
|
|
|
return jsonResponse;
|
|
|
|
return jsonResponse;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|