From 6c944758edc318d55e80dd04257aa30f33a0ea82 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sun, 17 Feb 2013 19:18:25 -0800 Subject: [PATCH] fixed renamed OID to id in json response. --- .../Datastore/ObjectDatabaseFixture.cs | 8 +++--- .../Datastore/SimpleRepositoryFixture.cs | 2 +- NzbDrone.Core/Datastore/BasicRepository.cs | 2 +- .../{BaseRepositoryModel.cs => ModelBase.cs} | 4 ++- NzbDrone.Core/Datastore/SiaqodbProxy.cs | 26 +++++++++---------- NzbDrone.Core/Helpers/XElementHelper.cs | 2 -- NzbDrone.Core/NzbDrone.Core.csproj | 2 +- NzbDrone.Core/RootFolders/RootFolder.cs | 2 +- 8 files changed, 24 insertions(+), 24 deletions(-) rename NzbDrone.Core/Datastore/{BaseRepositoryModel.cs => ModelBase.cs} (56%) diff --git a/NzbDrone.Core.Test/Datastore/ObjectDatabaseFixture.cs b/NzbDrone.Core.Test/Datastore/ObjectDatabaseFixture.cs index 46f2d5c93..58e9da80b 100644 --- a/NzbDrone.Core.Test/Datastore/ObjectDatabaseFixture.cs +++ b/NzbDrone.Core.Test/Datastore/ObjectDatabaseFixture.cs @@ -168,12 +168,12 @@ namespace NzbDrone.Core.Test.Datastore } } - public class UnknownType : BaseRepositoryModel + public class UnknownType : ModelBase { public string Field1 { get; set; } } - public class NestedModel : BaseRepositoryModel + public class NestedModel : ModelBase { public NestedModel() { @@ -183,12 +183,12 @@ namespace NzbDrone.Core.Test.Datastore public List List { get; set; } } - public class ParentModel : BaseRepositoryModel + public class ParentModel : ModelBase { public ChildModel Child { get; set; } } - public class ChildModel : BaseRepositoryModel + public class ChildModel : ModelBase { public String A { get; set; } diff --git a/NzbDrone.Core.Test/Datastore/SimpleRepositoryFixture.cs b/NzbDrone.Core.Test/Datastore/SimpleRepositoryFixture.cs index 914e439e9..3e5e4de4c 100644 --- a/NzbDrone.Core.Test/Datastore/SimpleRepositoryFixture.cs +++ b/NzbDrone.Core.Test/Datastore/SimpleRepositoryFixture.cs @@ -9,7 +9,7 @@ using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.Datastore { - public class SampleType : BaseRepositoryModel + public class SampleType : ModelBase { public string Name { get; set; } public string Tilte { get; set; } diff --git a/NzbDrone.Core/Datastore/BasicRepository.cs b/NzbDrone.Core/Datastore/BasicRepository.cs index 182e3b010..97e71e88d 100644 --- a/NzbDrone.Core/Datastore/BasicRepository.cs +++ b/NzbDrone.Core/Datastore/BasicRepository.cs @@ -11,7 +11,7 @@ namespace NzbDrone.Core.Datastore void Delete(int id); } - public class BasicRepository : IBasicRepository where TModel : BaseRepositoryModel, new() + public class BasicRepository : IBasicRepository where TModel : ModelBase, new() { public BasicRepository(IObjectDatabase objectDatabase) { diff --git a/NzbDrone.Core/Datastore/BaseRepositoryModel.cs b/NzbDrone.Core/Datastore/ModelBase.cs similarity index 56% rename from NzbDrone.Core/Datastore/BaseRepositoryModel.cs rename to NzbDrone.Core/Datastore/ModelBase.cs index d85f6aae2..caac2cb2e 100644 --- a/NzbDrone.Core/Datastore/BaseRepositoryModel.cs +++ b/NzbDrone.Core/Datastore/ModelBase.cs @@ -1,10 +1,12 @@ using System.Linq; +using Newtonsoft.Json; namespace NzbDrone.Core.Datastore { - public abstract class BaseRepositoryModel + public abstract class ModelBase { [PetaPoco.Ignore] + [JsonProperty(PropertyName = "id")] public int OID { get; set; } } } diff --git a/NzbDrone.Core/Datastore/SiaqodbProxy.cs b/NzbDrone.Core/Datastore/SiaqodbProxy.cs index eb2176dff..baf4ae30c 100644 --- a/NzbDrone.Core/Datastore/SiaqodbProxy.cs +++ b/NzbDrone.Core/Datastore/SiaqodbProxy.cs @@ -8,12 +8,12 @@ namespace NzbDrone.Core.Datastore public interface IObjectDatabase : IDisposable { IEnumerable AsQueryable(); - T Insert(T obj) where T : BaseRepositoryModel; - T Update(T obj) where T : BaseRepositoryModel; - IList InsertMany(IList objects) where T : BaseRepositoryModel; - IList UpdateMany(IList objects) where T : BaseRepositoryModel; - void Delete(T obj) where T : BaseRepositoryModel; - void DeleteMany(IEnumerable objects) where T : BaseRepositoryModel; + T Insert(T obj) where T : ModelBase; + T Update(T obj) where T : ModelBase; + IList InsertMany(IList objects) where T : ModelBase; + IList UpdateMany(IList objects) where T : ModelBase; + void Delete(T obj) where T : ModelBase; + void DeleteMany(IEnumerable objects) where T : ModelBase; } public class SiaqodbProxy : IObjectDatabase @@ -35,7 +35,7 @@ namespace NzbDrone.Core.Datastore return _db.Cast(); } - public T Insert(T obj) where T : BaseRepositoryModel + public T Insert(T obj) where T : ModelBase { if (obj.OID != 0) { @@ -46,7 +46,7 @@ namespace NzbDrone.Core.Datastore return obj; } - public T Update(T obj) where T : BaseRepositoryModel + public T Update(T obj) where T : ModelBase { if (obj.OID == 0) { @@ -57,23 +57,23 @@ namespace NzbDrone.Core.Datastore return obj; } - public IList InsertMany(IList objects) where T : BaseRepositoryModel + public IList InsertMany(IList objects) where T : ModelBase { return DoMany(objects, Insert); } - public IList UpdateMany(IList objects) where T : BaseRepositoryModel + public IList UpdateMany(IList objects) where T : ModelBase { return DoMany(objects, Update); } - public void Delete(T obj) where T : BaseRepositoryModel + public void Delete(T obj) where T : ModelBase { _db.Delete(obj); } - public void DeleteMany(IEnumerable objects) where T : BaseRepositoryModel + public void DeleteMany(IEnumerable objects) where T : ModelBase { foreach (var o in objects) { @@ -81,7 +81,7 @@ namespace NzbDrone.Core.Datastore } } - private IList DoMany(IEnumerable objects, Func function) where T : BaseRepositoryModel + private IList DoMany(IEnumerable objects, Func function) where T : ModelBase { return objects.Select(function).ToList(); } diff --git a/NzbDrone.Core/Helpers/XElementHelper.cs b/NzbDrone.Core/Helpers/XElementHelper.cs index d455474dd..bc1c093b2 100644 --- a/NzbDrone.Core/Helpers/XElementHelper.cs +++ b/NzbDrone.Core/Helpers/XElementHelper.cs @@ -1,8 +1,6 @@ using System; -using System.Collections.Generic; using System.ComponentModel; using System.Linq; -using System.Text; using System.Xml.Linq; namespace NzbDrone.Core.Helpers diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index fc9364587..49141fb14 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -251,7 +251,7 @@ - + diff --git a/NzbDrone.Core/RootFolders/RootFolder.cs b/NzbDrone.Core/RootFolders/RootFolder.cs index a14f233ba..86288c371 100644 --- a/NzbDrone.Core/RootFolders/RootFolder.cs +++ b/NzbDrone.Core/RootFolders/RootFolder.cs @@ -4,7 +4,7 @@ using Sqo.Attributes; namespace NzbDrone.Core.RootFolders { - public class RootFolder : BaseRepositoryModel + public class RootFolder : ModelBase { public string Path { get; set; }