mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Fixing local repository management of already loaded entities
This commit is contained in:
parent
cdf5acbbe9
commit
6958745915
@ -277,22 +277,28 @@ namespace Kyoo.Controllers
|
|||||||
|
|
||||||
Task<T> IRepository<T>.Create(T item)
|
Task<T> IRepository<T>.Create(T item)
|
||||||
{
|
{
|
||||||
TInternal obj = new TInternal();
|
TInternal obj = item as TInternal ?? new TInternal();
|
||||||
Utility.Assign(obj, item);
|
if (!(item is TInternal))
|
||||||
|
Utility.Assign(obj, item);
|
||||||
|
|
||||||
return Create(obj).Cast<T>()
|
return Create(obj).Cast<T>()
|
||||||
.Then(x => item.ID = x.ID);
|
.Then(x => item.ID = x.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
Task<T> IRepository<T>.CreateIfNotExists(T item)
|
Task<T> IRepository<T>.CreateIfNotExists(T item)
|
||||||
{
|
{
|
||||||
TInternal obj = new TInternal();
|
TInternal obj = item as TInternal ?? new TInternal();
|
||||||
Utility.Assign(obj, item);
|
if (!(item is TInternal))
|
||||||
|
Utility.Assign(obj, item);
|
||||||
|
|
||||||
return CreateIfNotExists(obj).Cast<T>()
|
return CreateIfNotExists(obj).Cast<T>()
|
||||||
.Then(x => item.ID = x.ID);
|
.Then(x => item.ID = x.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<T> Edit(T edited, bool resetOld)
|
public Task<T> Edit(T edited, bool resetOld)
|
||||||
{
|
{
|
||||||
|
if (edited is TInternal intern)
|
||||||
|
return Edit(intern, resetOld).Cast<T>();
|
||||||
TInternal obj = new TInternal();
|
TInternal obj = new TInternal();
|
||||||
Utility.Assign(obj, edited);
|
Utility.Assign(obj, edited);
|
||||||
return base.Edit(obj, resetOld).Cast<T>();
|
return base.Edit(obj, resetOld).Cast<T>();
|
||||||
@ -302,6 +308,8 @@ namespace Kyoo.Controllers
|
|||||||
|
|
||||||
Task IRepository<T>.Delete(T obj)
|
Task IRepository<T>.Delete(T obj)
|
||||||
{
|
{
|
||||||
|
if (obj is TInternal intern)
|
||||||
|
return Delete(intern);
|
||||||
TInternal item = new TInternal();
|
TInternal item = new TInternal();
|
||||||
Utility.Assign(item, obj);
|
Utility.Assign(item, obj);
|
||||||
return Delete(item);
|
return Delete(item);
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 735a0e6a1a7ae2653de45b47adc823275a46478d
|
Subproject commit 0f3faa21fad37b2ed39317d58aa3e295fa1c3a41
|
Loading…
x
Reference in New Issue
Block a user