Fix osai tool update
This commit is contained in:
+18
-3
@@ -1771,19 +1771,34 @@ namespace Step.NC
|
||||
}
|
||||
}
|
||||
|
||||
public CmsError UpdateTool(int toolId, DTONewNcToolModel newTool, out DTONcToolModel toolWithOffsets)
|
||||
public CmsError UpdateTool(int toolId, DTONewNcToolModel newTool, out DTONcToolModel toolWithOffsets, DTONewNcToolWithFamilyModel dtoToolWithFamily)
|
||||
{
|
||||
toolWithOffsets = new DTONcToolModel();
|
||||
|
||||
CmsError cmsError = NO_ERROR;
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
using (var dbContextTransaction = toolsManager.dbCtx.Database.BeginTransaction())
|
||||
{
|
||||
// If option is active
|
||||
if (!ToolManagerConfig.FamilyOpt)
|
||||
{
|
||||
// Copy only family
|
||||
DTONewNcFamilyModel newFamily = new DTONewNcFamilyModel();
|
||||
SupportFunctions.CopyProperties(dtoToolWithFamily, newFamily);
|
||||
// Update only family data
|
||||
newFamily = (DTONcFamilyModel)toolsManager.UpdateFamily(dtoToolWithFamily.FamilyId, newFamily);
|
||||
|
||||
// Update Nc families
|
||||
cmsError = UpdateNcFamily(toolsManager);
|
||||
if (cmsError.IsError())
|
||||
ManageErrorAndTransaction(cmsError, dbContextTransaction, true);
|
||||
}
|
||||
|
||||
// Update database tool Tool
|
||||
DbNcToolModel dbTool = toolsManager.UpdateTool(toolId, newTool);
|
||||
|
||||
// Populate updated tool with offset data
|
||||
CmsError cmsError = GetToolData(dbTool, ref toolWithOffsets);
|
||||
cmsError = GetToolData(dbTool, ref toolWithOffsets);
|
||||
if (cmsError.IsError())
|
||||
{
|
||||
dbContextTransaction.Rollback();
|
||||
|
||||
@@ -155,22 +155,9 @@ namespace Step.Controllers.WebApi
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
ncHandler.Connect();
|
||||
|
||||
CmsError cmsError;
|
||||
// If option is active
|
||||
if (!ToolManagerConfig.FamilyOpt)
|
||||
{
|
||||
// Copy only family
|
||||
DTONewNcFamilyModel newFamily = new DTONewNcFamilyModel();
|
||||
SupportFunctions.CopyProperties(dtoToolWithFamily, newFamily);
|
||||
// Update only family data
|
||||
cmsError = ncHandler.UpdateFamily(dtoToolWithFamily.FamilyId, newFamily, out DTONcFamilyModel newFam);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
}
|
||||
|
||||
|
||||
// Update
|
||||
cmsError = ncHandler.UpdateTool(toolId, dtoToolWithFamily, out DTONcToolModel newTool);
|
||||
CmsError cmsError = ncHandler.UpdateTool(toolId, dtoToolWithFamily, out DTONcToolModel newTool, dtoToolWithFamily);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user