Fix backup

Added copy properties between class functions
This commit is contained in:
Lucio Maranta
2018-07-18 17:24:07 +02:00
parent bf8754fe71
commit 08b0bafc56
4 changed files with 44 additions and 17 deletions
@@ -1,5 +1,6 @@
using Step.Model.DatabaseModels;
using Step.Model.DTOModels.ToolModels;
using Step.Utils;
using System;
using System.Collections.Generic;
using System.Data.Entity;
@@ -224,14 +225,16 @@ namespace Step.Database.Controllers
public DbNcToolModel UpdateTool(int toolId, DTONewNcToolModel dtoTool)
{
DbNcToolModel tool = FindTool(toolId);
// Update db model
tool.FamilyId = dtoTool.FamilyId;
tool.OffsetLength = dtoTool.OffsetLength;
tool.ResidualLife = dtoTool.ResidualLife;
tool.ResidualRevive = dtoTool.ResidualRevive;
tool.OffsetId1 = dtoTool.OffsetId1;
tool.OffsetId2 = dtoTool.OffsetId2;
tool.OffsetId3 = dtoTool.OffsetId3;
SupportFunctions.CopyProperties(dtoTool, tool);
//tool.FamilyId = dtoTool.FamilyId;
//tool.OffsetLength = dtoTool.OffsetLength;
//tool.ResidualLife = dtoTool.ResidualLife;
//tool.ResidualRevive = dtoTool.ResidualRevive;
//tool.OffsetId1 = dtoTool.OffsetId1;
//tool.OffsetId2 = dtoTool.OffsetId2;
//tool.OffsetId3 = dtoTool.OffsetId3;
// Save
dbCtx.SaveChanges();
@@ -265,10 +268,10 @@ namespace Step.Database.Controllers
public DbNcFamilyModel UpdateFamily(int familyId, DTONewNcFamilyModel family)
{
DbNcFamilyModel dbFamily = FindFamily(familyId);
dbFamily = (DbNcFamilyModel)family;
SupportFunctions.CopyProperties(family, dbFamily);
dbCtx.SaveChanges();
dbCtx.Families.Attach(dbFamily);
return dbFamily;
}