- correzione update tags da lettura dati
This commit is contained in:
Samuele Locatelli
2022-12-29 16:32:41 +01:00
parent e0a349e301
commit 8be3041eff
7 changed files with 32 additions and 18 deletions
+23 -5
View File
@@ -153,6 +153,11 @@ namespace MP.FileData.Controllers
}
Log.Info($"Effettuati {checkDone} controlli");
// svuoto
fileNew = new List<FileInfo>();
fileChecked = new List<FileModel>();
fileMod = new List<FileModel>();
// chiudo
return checkDone;
}
@@ -267,6 +272,7 @@ namespace MP.FileData.Controllers
dbResult = localDbCtx
.DbSetProgFile
.Where(x => x.Path.StartsWith(path) && ((onlyActive == x.Active) || !onlyActive))
.Include(x => x.Tags)
.OrderBy(x => x.Name)
.ToList();
}
@@ -500,12 +506,21 @@ namespace MP.FileData.Controllers
List<TagModel> currTags = localDbCtx.DbSetTags.ToList();
foreach (var item in updFiles)
{
// recupero record da DB...
var currItem = localDbCtx
.DbSetProgFile
.Where(x => x.FileId == item.FileId)
.Include(x => x.Tags)
.FirstOrDefault();
#if false
// rimuovo tags vecchi
if (item.Tags != null)
if (currItem.Tags != null)
{
item.Tags.Clear();
localDbCtx.SaveChanges();
}
currItem.Tags.Clear();
//localDbCtx.Entry(item).State = EntityState.Modified;
//localDbCtx.SaveChanges();
}
#endif
List<string> Tags = new List<string>();
List<TagModel> Tag4File = new List<TagModel>();
@@ -552,8 +567,11 @@ namespace MP.FileData.Controllers
if (Tag4File.Count > 0)
{
// salvo i tags relativi ai files
item.Tags = Tag4File;
currItem.Tags.Clear();
currItem.Tags = Tag4File;
//localDbCtx.Entry(currItem).State = EntityState.Modified;
}
//localDbCtx.SaveChanges();
}
try
{