mirror of
https://github.com/zoriya/Kyoo.git
synced 2026-05-21 14:46:29 -04:00
Fixing local repository management of already loaded entities
This commit is contained in:
@@ -277,22 +277,28 @@ namespace Kyoo.Controllers
|
||||
|
||||
Task<T> IRepository<T>.Create(T item)
|
||||
{
|
||||
TInternal obj = new TInternal();
|
||||
Utility.Assign(obj, item);
|
||||
TInternal obj = item as TInternal ?? new TInternal();
|
||||
if (!(item is TInternal))
|
||||
Utility.Assign(obj, item);
|
||||
|
||||
return Create(obj).Cast<T>()
|
||||
.Then(x => item.ID = x.ID);
|
||||
}
|
||||
|
||||
Task<T> IRepository<T>.CreateIfNotExists(T item)
|
||||
{
|
||||
TInternal obj = new TInternal();
|
||||
Utility.Assign(obj, item);
|
||||
TInternal obj = item as TInternal ?? new TInternal();
|
||||
if (!(item is TInternal))
|
||||
Utility.Assign(obj, item);
|
||||
|
||||
return CreateIfNotExists(obj).Cast<T>()
|
||||
.Then(x => item.ID = x.ID);
|
||||
}
|
||||
|
||||
public Task<T> Edit(T edited, bool resetOld)
|
||||
{
|
||||
if (edited is TInternal intern)
|
||||
return Edit(intern, resetOld).Cast<T>();
|
||||
TInternal obj = new TInternal();
|
||||
Utility.Assign(obj, edited);
|
||||
return base.Edit(obj, resetOld).Cast<T>();
|
||||
@@ -302,6 +308,8 @@ namespace Kyoo.Controllers
|
||||
|
||||
Task IRepository<T>.Delete(T obj)
|
||||
{
|
||||
if (obj is TInternal intern)
|
||||
return Delete(intern);
|
||||
TInternal item = new TInternal();
|
||||
Utility.Assign(item, obj);
|
||||
return Delete(item);
|
||||
|
||||
+1
-1
Submodule Kyoo/Views/WebClient updated: 735a0e6a1a...0f3faa21fa
Reference in New Issue
Block a user