|
@@ -372,6 +372,18 @@ namespace Luticate2.Utils.DataAccess
|
372
|
372
|
// return EditSingleById(id, update, read => read);
|
373
|
373
|
// }
|
374
|
374
|
|
|
375
|
+ protected void SyncManyToMany<T>(IList<TId> ids, IList<T> verbs, Func<TId, T> newVerb, Func<T, TId> getVerbFk)
|
|
376
|
+ {
|
|
377
|
+ foreach (var added in ids.Where(id => verbs.FirstOrDefault(o => Equals(getVerbFk(o), id)) == null))
|
|
378
|
+ {
|
|
379
|
+ verbs.Add(newVerb(added));
|
|
380
|
+ }
|
|
381
|
+ foreach (var removed in verbs.Where(v => ids.FirstOrDefault(id => Equals(getVerbFk(v), id)) == null).ToList())
|
|
382
|
+ {
|
|
383
|
+ verbs.Remove(removed);
|
|
384
|
+ }
|
|
385
|
+ }
|
|
386
|
+
|
375
|
387
|
protected virtual LuResult<bool> _EditSingleById(TModel model, TDboUpdate update, TDbContext db, DbSet<TModel> table)
|
376
|
388
|
{
|
377
|
389
|
return LuResult<bool>.Ok(true);
|