1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00

fixed renamed OID to id in json response.

This commit is contained in:
kay.one 2013-02-17 19:18:25 -08:00
parent c904c6e085
commit 6c944758ed
8 changed files with 24 additions and 24 deletions

View File

@ -168,12 +168,12 @@ public void should_be_able_to_read_unknown_type()
}
}
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 @@ public NestedModel()
public List<NestedModel> 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; }

View File

@ -9,7 +9,7 @@
namespace NzbDrone.Core.Test.Datastore
{
public class SampleType : BaseRepositoryModel
public class SampleType : ModelBase
{
public string Name { get; set; }
public string Tilte { get; set; }

View File

@ -11,7 +11,7 @@ public interface IBasicRepository<TModel>
void Delete(int id);
}
public class BasicRepository<TModel> : IBasicRepository<TModel> where TModel : BaseRepositoryModel, new()
public class BasicRepository<TModel> : IBasicRepository<TModel> where TModel : ModelBase, new()
{
public BasicRepository(IObjectDatabase objectDatabase)
{

View File

@ -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; }
}
}

View File

@ -8,12 +8,12 @@ namespace NzbDrone.Core.Datastore
public interface IObjectDatabase : IDisposable
{
IEnumerable<T> AsQueryable<T>();
T Insert<T>(T obj) where T : BaseRepositoryModel;
T Update<T>(T obj) where T : BaseRepositoryModel;
IList<T> InsertMany<T>(IList<T> objects) where T : BaseRepositoryModel;
IList<T> UpdateMany<T>(IList<T> objects) where T : BaseRepositoryModel;
void Delete<T>(T obj) where T : BaseRepositoryModel;
void DeleteMany<T>(IEnumerable<T> objects) where T : BaseRepositoryModel;
T Insert<T>(T obj) where T : ModelBase;
T Update<T>(T obj) where T : ModelBase;
IList<T> InsertMany<T>(IList<T> objects) where T : ModelBase;
IList<T> UpdateMany<T>(IList<T> objects) where T : ModelBase;
void Delete<T>(T obj) where T : ModelBase;
void DeleteMany<T>(IEnumerable<T> objects) where T : ModelBase;
}
public class SiaqodbProxy : IObjectDatabase
@ -35,7 +35,7 @@ public IEnumerable<T> AsQueryable<T>()
return _db.Cast<T>();
}
public T Insert<T>(T obj) where T : BaseRepositoryModel
public T Insert<T>(T obj) where T : ModelBase
{
if (obj.OID != 0)
{
@ -46,7 +46,7 @@ public T Insert<T>(T obj) where T : BaseRepositoryModel
return obj;
}
public T Update<T>(T obj) where T : BaseRepositoryModel
public T Update<T>(T obj) where T : ModelBase
{
if (obj.OID == 0)
{
@ -57,23 +57,23 @@ public T Update<T>(T obj) where T : BaseRepositoryModel
return obj;
}
public IList<T> InsertMany<T>(IList<T> objects) where T : BaseRepositoryModel
public IList<T> InsertMany<T>(IList<T> objects) where T : ModelBase
{
return DoMany(objects, Insert);
}
public IList<T> UpdateMany<T>(IList<T> objects) where T : BaseRepositoryModel
public IList<T> UpdateMany<T>(IList<T> objects) where T : ModelBase
{
return DoMany(objects, Update);
}
public void Delete<T>(T obj) where T : BaseRepositoryModel
public void Delete<T>(T obj) where T : ModelBase
{
_db.Delete(obj);
}
public void DeleteMany<T>(IEnumerable<T> objects) where T : BaseRepositoryModel
public void DeleteMany<T>(IEnumerable<T> objects) where T : ModelBase
{
foreach (var o in objects)
{
@ -81,7 +81,7 @@ public void DeleteMany<T>(IEnumerable<T> objects) where T : BaseRepositoryModel
}
}
private IList<T> DoMany<T>(IEnumerable<T> objects, Func<T, T> function) where T : BaseRepositoryModel
private IList<T> DoMany<T>(IEnumerable<T> objects, Func<T, T> function) where T : ModelBase
{
return objects.Select(function).ToList();
}

View File

@ -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

View File

@ -251,7 +251,7 @@
</Compile>
<Compile Include="Constants.cs" />
<Compile Include="ContainerExtentions.cs" />
<Compile Include="Datastore\BaseRepositoryModel.cs" />
<Compile Include="Datastore\ModelBase.cs" />
<Compile Include="Datastore\BasicRepository.cs" />
<Compile Include="Datastore\ConnectionFactory.cs" />
<Compile Include="Datastore\ObjectDbFactory.cs" />

View File

@ -4,7 +4,7 @@
namespace NzbDrone.Core.RootFolders
{
public class RootFolder : BaseRepositoryModel
public class RootFolder : ModelBase
{
public string Path { get; set; }