Fix import-export tool table

Fix mag position page
This commit is contained in:
Lucio Maranta
2019-03-29 12:38:55 +01:00
parent 3ae585b734
commit 0ad395bebf
10 changed files with 81 additions and 38 deletions
@@ -557,6 +557,8 @@ namespace Step.Database.Controllers
Tools = FindTools(),
Families = FindFamilies(),
Shanks = FindShanks()
.Select(x => { x.MagazineId = null; x.PositionId = null; return x; })
.ToList()
};
}
@@ -566,29 +568,32 @@ namespace Step.Database.Controllers
List<DbNcFamilyModel> families = FindFamilies();
List<DbNcShankModel> shanks = FindShanks();
// loop thought new families
foreach (var family in data.Families)
{
// Check if not exist
if (families.FirstOrDefault(x => x.FamilyId == family.FamilyId) == null)
dbCtx.Families.Add(family);
}
if(data.Families != null)
// loop thought new families
foreach (var family in data.Families)
{
// Check if not exist
if (families.FirstOrDefault(x => x.FamilyId == family.FamilyId) == null)
dbCtx.Families.Add(family);
}
// loop thought new shanks
foreach (var shank in data.Shanks)
{
// Check if not exist
if (shanks.FirstOrDefault(x => x.ShankId == shank.ShankId) == null)
dbCtx.Shanks.Add(shank);
}
if(data.Shanks != null)
// loop thought new shanks
foreach (var shank in data.Shanks)
{
// Check if not exist
if (shanks.FirstOrDefault(x => x.ShankId == shank.ShankId) == null)
dbCtx.Shanks.Add(shank);
}
// loop thought new tools
foreach (var tool in data.Tools)
{
// Check if not exist
if (tools.FirstOrDefault(x => x.ToolId == tool.ToolId) == null)
dbCtx.Tools.Add(tool);
}
if(data.Tools != null)
// loop thought new tools
foreach (var tool in data.Tools)
{
// Check if not exist
if (tools.FirstOrDefault(x => x.ToolId == tool.ToolId) == null)
dbCtx.Tools.Add(tool);
}
// Save
dbCtx.SaveChanges();