public ApiResponse <TransformationModel> Post([FromRoute] Guid packageId, [FromBody] TransformationModel request) { // Create the response object ApiResponse <TransformationModel> response = new ApiResponse <TransformationModel>(); // Map the model to a domain object type Transformation savedConnection = mapper.Map <Transformation>(request); // Did the mapping work ok? if (savedConnection != null) { // Did we find a package? Package package = SessionHandler.PackageRepository.Get(packageId); if (package != null) { // Get the repository to save the package for us savedConnection = package.Save <Transformation>(savedConnection); } // Saved ok? if (savedConnection != null) { // Map the connection back to a model type and send it back to the user response.Data = mapper.Map <TransformationModel>(savedConnection); } // Nothing died .. Success response.Success = true; } // Send the response back return(response); }
public TransformationModel XmlToObject(string xmlPath) { XDocument doc = XDocument.Load(xmlPath); var ChainObj = new TransformationModel(XmlEnum.Transformation); var processingStepObj = new ProcessingStepsModel(XmlEnum.ProcessingSteps); var processingSteps = doc.Descendants("Map"); foreach (var step in processingSteps) { var MapObj = new MapModel(XmlEnum.Map); var BasObj = new CodeModulePathModel(XmlEnum.CodeModulePath); var BasesObj = new CodeModulesModel(XmlEnum.CodeModules); var VariableObj = new VariableModel(XmlEnum.TransformationVariables); var VariablesObj = new TransformationVariablesModel(XmlEnum.TransformationVariables); var Bas = step.Descendants("CodeModules"); foreach (var b in Bas) { BasObj.AddCodeModulePathModel(XmlEnum.CodeModulePath, b.Element("CodeModulePath").Attribute("Location").Value); BasesObj.AddCodeModule(BasObj); } var TransformationVariables = step.Descendants("TransformationVariables").Elements("Variable"); foreach (var v in TransformationVariables) { VariableObj.AddVariable(XmlEnum.Variable, v.Attribute("Value").Value, v.Attribute("IsPublic").Value, v.Attribute("InitialValue").Value); VariablesObj.AddVariable(VariableObj); } MapObj.AddMap(XmlEnum.Map, step.Attribute("Sequence").Value, step.Attribute("Name").Value, step.Element("MapFilePath").Attribute("Location").Value, step.Element("SourceFilePath").Attribute("Location").Value, step.Element("TargetFilePath").Attribute("Location").Value, BasesObj, VariablesObj); processingStepObj.AddMap(MapObj); } var Chain = doc.Descendants("Transformation"); foreach (var t in Chain) { ChainObj.AddTransformationModel(XmlEnum.Transformation, t.Attribute("createdon").Value, t.Attribute("createdby").Value, processingStepObj); } return(ChainObj); }