public static void AddTableTitle(string tableName, ExcelWorksheet wsSheet1, tDecisionTable decisionTable, string tableId) { wsSheet1.Cells["B1"].Value = "DMN Navn:"; wsSheet1.Cells["C1"].Value = tableName; wsSheet1.Cells["B2"].Value = "DMN id:"; wsSheet1.Cells["C2"].Value = tableId; wsSheet1.Cells["B1"].Style.Font.Size = 12; wsSheet1.Cells["B1"].Style.Font.Bold = true; wsSheet1.Cells["B1"].Style.Font.Italic = true; wsSheet1.Cells["B2"].Style.Font.Size = 12; wsSheet1.Cells["B2"].Style.Font.Bold = true; wsSheet1.Cells["B2"].Style.Font.Italic = true; }
public void Test1() { var file = "dmnTest1.dmn"; string ifcDataFile = Path.Combine(Directory.GetCurrentDirectory() + @"..\..\..\..\TestData\", file); tDefinitions dmn; using (Stream dmnStream = File.Open(ifcDataFile, FileMode.Open)) { dmn = new DmnServices().DeserializeStreamDmnFile(dmnStream); } var Items = dmn.Items; var decision = Items.Where(t => t.GetType() == typeof(tDecision)); var excelPkg = new ExcelPackage(); foreach (var tdecision in decision) { tDecisionTable decisionTable = null; try { var dt = ((tDecision)tdecision).Item; decisionTable = (tDecisionTable)Convert.ChangeType(dt, typeof(tDecisionTable)); ExcelWorksheet wsSheet = excelPkg.Workbook.Worksheets.Add(tdecision.id); //Add Table Title ExcelServices.AddTableTitle(tdecision.name, wsSheet, decisionTable, tdecision.id); // Add "input" and "output" headet to Excel table ExcelServices.AddTableInputOutputTitle(wsSheet, decisionTable); //Add DMN Table to excel Sheet ExcelServices.CreateExcelTableFromDecisionTable(decisionTable, wsSheet, tdecision.id); } catch { // } } var filename = Path.GetFileNameWithoutExtension(ifcDataFile); var path = string.Concat(@"c:\temp\"); Directory.CreateDirectory(path); var filePath = Path.Combine(path, string.Concat(filename, ".xlsx")); excelPkg?.SaveAs(new FileInfo(filePath)); File.Exists(filePath).Should().BeTrue(); }
public DmnV1Builder AddOutputsToDecisionTable(Dictionary <string, Dictionary <string, string> > outputsDictionary, Dictionary <int, string> outputsType) { tDecisionTable decisionTable = null; if (_dmn.Items != null) { var decision = _dmn.Items.FirstOrDefault(i => i is tDecision); decisionTable = (tDecisionTable)((tDecision)decision)?.Item; } if (decisionTable != null) { decisionTable.output = CreateDmnOutpus(outputsDictionary, outputsType); } return(this); }
public tDefinitions SerializeDictionariesToDmn(Dictionary <string, object> outputsDictionary, Dictionary <int, object> rulesDictionary, string fileName) { var tDecisionTable = new tDecisionTable(); tDecisionTable.input = new tInputClause[] { }; var tExpression = tDecisionTable; var tdecision = new tDecision(); tdecision.Item = tExpression; var tDefinitions = new tDefinitions(); tDefinitions.id = fileName; tDefinitions.Items = new tDRGElement[] { tdecision }; return(tDefinitions); }
public static void AddTableInputOutputTitle(ExcelWorksheet wsSheet, tDecisionTable decisionTable) { var totalInput = decisionTable.input.Count(); var totalOutput = decisionTable.output.Count(); const int stratRow = 4; const int stratColumn = 2; var endInputColumn = stratColumn + totalInput; var endColum = endInputColumn + totalOutput; //input using (ExcelRange rng = wsSheet.Cells[stratRow, stratColumn, stratRow, endInputColumn - 1]) { InputOutputTitleFormat(rng, "Input"); } //Output using (ExcelRange rng = wsSheet.Cells[stratRow, endInputColumn, stratRow, endColum]) { InputOutputTitleFormat(rng, "Output"); } }
public static void AddTableInputOutputTitle(ExcelWorksheet wsSheet, tDecisionTable decisionTable) { var totalInput = decisionTable.input.Count(); var totalOutput = decisionTable.output.Count(); //input var endInputsCellAddress = AddRowAndColumnToCellAddress(_StartCell, 0, totalInput - 1); using (ExcelRange rng = wsSheet.Cells[$"{_StartCell}:{endInputsCellAddress}"]) { InputOutputTitleFormat(rng, "Input"); } //Output var startOutputsCellAddress = AddRowAndColumnToCellAddress(endInputsCellAddress, 0, 1); var endOutputsCellAddress = AddRowAndColumnToCellAddress(endInputsCellAddress, 0, totalOutput + 1); using (ExcelRange rng = wsSheet.Cells[$"{startOutputsCellAddress}:{endOutputsCellAddress}"]) { InputOutputTitleFormat(rng, "Output"); } }
public DmnV1Builder AddInputsToDecisionTable(Dictionary <string, Dictionary <string, string> > inputsDictionary, Dictionary <int, string> inputsTypes) { tDecisionTable decisionTable = null; if (_dmn.Items == null) { _dmn.Items = new[] { new tDecision() { Item = new tDecisionTable(), }, }; } var decision = _dmn.Items.FirstOrDefault(i => i is tDecision); decisionTable = (tDecisionTable)((tDecision)decision)?.Item; if (decisionTable != null) { decisionTable.input = CreateDmnInputs(inputsDictionary, inputsTypes); } return(this); }
public void Test1() { var file = "dmnTest1.dmn"; var file2 = "dmnTest2.dmn"; var file3 = "BpmnTest01.bpmn"; var dmns = new List <tDefinitions>(); var filePath1 = Path.Combine(Directory.GetCurrentDirectory() + @"..\..\..\..\Data\", file); var filePath2 = Path.Combine(Directory.GetCurrentDirectory() + @"..\..\..\..\Data\", file2); var bpmn = Path.Combine(Directory.GetCurrentDirectory() + @"..\..\..\..\Data\", file3); XDocument bpmnXml = XDocument.Load(bpmn); using (Stream dmnStream = File.Open(filePath1, FileMode.Open)) { dmns.Add(DmnConverter.DeserializeStreamDmnFile(dmnStream)); } using (Stream dmnStream = File.Open(filePath2, FileMode.Open)) { dmns.Add(DmnConverter.DeserializeStreamDmnFile(dmnStream)); } var dmnDataDictionaryModels = new List <DmnInfo>(); var excelPkg = new ExcelPackage(); foreach (var tdefinitions in dmns) { var Items = tdefinitions.Items; var decision = Items.Where(t => t.GetType() == typeof(tDecision)); foreach (tDecision tdecision in decision) { tDecisionTable decisionTable = null; try { DmnConverter.GetDecisionsVariables(tdecision, Path.GetFileNameWithoutExtension(filePath1), ref dmnDataDictionaryModels); } catch { // } } } var bpmnDataDictionary = new List <BpmnInfo>(); DmnConverter.GetDmnInfoFromBpmnModel(bpmnXml, dmnDataDictionaryModels, ref bpmnDataDictionary); //List<DataDictionaryModel> dataDictionaryModels = new List<DataDictionaryModel>(); foreach (var dmnData in dmnDataDictionaryModels) { var submodel = new BpmnInfo(); try { var value = dmnData.GetType(); var property = value.GetProperty("DmnId"); String name = (String)(property.GetValue(dmnData, null)); } catch { } //dataDictionaryModels.Add(new DataDictionaryModel() //{ // BpmnData = submodel, // DmnData = dmnData //}); } ExcelWorksheet wsSheet = excelPkg.Workbook.Worksheets.Add("DmnTEK"); //Filter all dmn by Id var dmnIds = dmnDataDictionaryModels.GroupBy(x => x.DmnId).Select(y => y.First()); var objectPropertyNames = new[] { "DmnId", "DmnName", "TekKapitel", "TekLedd", "TekTabell", "TekForskriften", "TekWebLink" }; ExcelConverter.CreateDmnExcelTableDataDictionary(dmnIds, wsSheet, "dmnTek", objectPropertyNames); ExcelWorksheet wsSheet1 = excelPkg.Workbook.Worksheets.Add("Variables"); var dmnVariablesIds = DmnConverter.GetVariablesFormDmns(dmnDataDictionaryModels); var dmnVariablesIdstPropertyNames = new[] { "VariabelId", "VariabelNavn", "VariabelBeskrivelse", "IFC4", "IfcUrl" }; ExcelConverter.CreateVariablesExcelTableDataDictionary(dmnVariablesIds, wsSheet1, "Variables", dmnVariablesIdstPropertyNames); ExcelWorksheet wsSheet2 = excelPkg.Workbook.Worksheets.Add("Dmn+Variables"); var objectPropertyNames1 = new[] { "DmnId", "VariabelId", "VariabelType" }; ExcelConverter.CreateDMNAndVariablesExcelTableDataDictionary(dmnIds, wsSheet2, "Dmn+Variables", objectPropertyNames1); ExcelWorksheet wsSheet3 = excelPkg.Workbook.Worksheets.Add("summary"); var summaryPropertyNames = new[] { "FileName", "BpmnId", "DmnId", "VariabelId", "VariabelType", "VariablesUseType", "Kilde" }; ExcelConverter.CreateSummaryExcelTableDataDictionary(bpmnDataDictionary, wsSheet3, "summary", summaryPropertyNames); var path = string.Concat(@"c:\temp\"); Directory.CreateDirectory(path); var filePath = Path.Combine(path, string.Concat("dataDictionary", ".xlsx")); excelPkg?.SaveAs(new FileInfo(filePath)); File.Exists(filePath).Should().BeTrue(); }
public static void CreateExcelTableFromDecisionTable(tDecisionTable decisionTable, ExcelWorksheet wsSheet, string tableName) { // palse Table in Excel // Calculate size of the table var totalInput = decisionTable.input.Count(); var totalOutput = decisionTable.output.Count(); var totalRules = decisionTable.rule.Count(); // Create Excel table Header var startTableCellAddress = AddRowAndColumnToCellAddress(_StartCell, 1, 0); var endTableCellAddress = AddRowAndColumnToCellAddress(startTableCellAddress, totalRules + 1, totalInput + totalOutput); using (ExcelRange rng = wsSheet.Cells[$"{startTableCellAddress}:{endTableCellAddress}"]) { ExcelTable table = wsSheet.Tables.Add(rng, tableName); //Set Columns Adress and values var i = 0; foreach (var inputClause in decisionTable.input) { var headerCellAddress = AddRowAndColumnToCellAddress(startTableCellAddress, 0, i); wsSheet.Cells[headerCellAddress].Value = inputClause.label; AddContentStyleToCell(wsSheet, headerCellAddress); //add input variableId name var cellAdress = AddRowAndColumnToCellAddress(startTableCellAddress, 1, i); wsSheet.Cells[cellAdress].Value = inputClause.inputExpression?.Item?.ToString(); AddIdStyleToCell(wsSheet, cellAdress); i++; } foreach (var outputClause in decisionTable.output) { var headerCellAddress = AddRowAndColumnToCellAddress(startTableCellAddress, 0, i); wsSheet.Cells[headerCellAddress].Value = outputClause.label; AddContentStyleToCell(wsSheet, headerCellAddress); // Add Output variableId name var cellAdress = AddRowAndColumnToCellAddress(startTableCellAddress, 1, i); var variableId = outputClause.name ?? ""; wsSheet.Cells[cellAdress].Value = variableId; AddIdStyleToCell(wsSheet, cellAdress); i++; } // Add empty cell for annotation table.Columns[i].Name = "Annotation"; wsSheet.Cells[AddRowAndColumnToCellAddress(startTableCellAddress, 1, i)].Value = ""; AddIdStyleToCell(wsSheet, AddRowAndColumnToCellAddress(startTableCellAddress, 1, i)); //table.ShowHeader = false; //table.ShowFilter = true; //table.ShowTotal = true; } for (int ruleCount = 0; ruleCount < decisionTable.rule.Length; ruleCount++) { var inputEntryLength = decisionTable.rule[ruleCount].inputEntry.Length; var outputEntryLength = decisionTable.rule[ruleCount].outputEntry.Length; //Add inputs values to table for (int inputsCount = 0; inputsCount < inputEntryLength; inputsCount++) { var value = decisionTable.rule[ruleCount].inputEntry[inputsCount].text; var cellAdress = AddRowAndColumnToCellAddress(startTableCellAddress, ruleCount + 2, inputsCount); wsSheet.Cells[cellAdress].Value = value; AddContentStyleToCell(wsSheet, cellAdress); wsSheet.Cells[AddRowAndColumnToCellAddress(startTableCellAddress, ruleCount + 2, inputsCount)].Style.Locked = false; } //Add outpus content values to Table for (int outputsCount = 0; outputsCount < outputEntryLength; outputsCount++) { var value = decisionTable.rule[ruleCount].outputEntry[outputsCount].Item?.ToString(); var cellAdress = AddRowAndColumnToCellAddress(startTableCellAddress, ruleCount + 2, inputEntryLength + outputsCount); wsSheet.Cells[cellAdress].Value = value; AddContentStyleToCell(wsSheet, cellAdress); } var annotationValue = decisionTable.rule[ruleCount].description; var annotationCellAdress = AddRowAndColumnToCellAddress(startTableCellAddress, ruleCount + 2, inputEntryLength + outputEntryLength); wsSheet.Cells[annotationCellAdress].Value = annotationValue; AddContentStyleToCell(wsSheet, annotationCellAdress); } wsSheet.Protection.AllowInsertRows = true; wsSheet.Protection.AllowDeleteRows = true; wsSheet.Protection.IsProtected = true; //wsSheet1.Protection.AllowSelectLockedCells = false; wsSheet.Cells[wsSheet.Dimension.Address].AutoFitColumns(); }
public static void CreateExcelTableFromDecisionTable(tDecisionTable decisionTable, ExcelWorksheet wsSheet, string tableName) { // palse Table in Excel const int stratRow = 5; const int stratColumn = 2; // Calculate size of the table var totalInput = decisionTable.input.Count(); var totalOutput = decisionTable.output.Count(); var totalRules = decisionTable.rule.Count(); var endRow = stratRow + totalRules + 1; var endColum = stratColumn + totalInput + totalOutput; // Create Excel table Header using (ExcelRange rng = wsSheet.Cells[stratRow, stratColumn, endRow, endColum]) { //Indirectly access ExcelTableCollection class ExcelTable table = wsSheet.Tables.Add(rng, tableName); var color = Color.FromArgb(250, 199, 111); //Set Columns position & name var i = 0; foreach (var inputClause in decisionTable.input) { table.Columns[i].Name = inputClause.label; //add input variable name AddExcelCellByRowAndColumn(stratColumn + i, stratRow + 1, inputClause.inputExpression.Item.ToString(), wsSheet, color); i++; } foreach (var outputClause in decisionTable.output) { table.Columns[i].Name = outputClause.label; // Add Output variableId name var variableId = outputClause.name ?? ""; AddExcelCellByRowAndColumn(stratColumn + i, stratRow + 1, variableId, wsSheet, color); i++; } // Add empty cell for annotation table.Columns[i].Name = "Annotation"; AddExcelCellByRowAndColumn(stratColumn + i, stratRow + 1, " ", wsSheet, color); //table.ShowHeader = false; //table.ShowFilter = true; //table.ShowTotal = true; } // Set Excel table content var inputColumn = stratColumn; var outputColumn = stratColumn + totalInput; var row = stratRow + 1; foreach (var rule in decisionTable.rule) { // input content row++; foreach (var tUnaryTestse in rule.inputEntry) { AddExcelCellByRowAndColumn(inputColumn, row, tUnaryTestse.text, wsSheet); inputColumn++; } inputColumn = stratColumn; // set Output result content foreach (var literalExpression in rule.outputEntry) { AddExcelCellByRowAndColumn(outputColumn, row, literalExpression.Item.ToString(), wsSheet); outputColumn++; } var annotationCellName = string.Concat(GetColumnName(endColum), row); using (ExcelRange rng = wsSheet.Cells[annotationCellName]) { rng.Value = rule.description; } outputColumn = stratColumn + totalInput; } //wsSheet1.Protection.IsProtected = false; //wsSheet1.Protection.AllowSelectLockedCells = false; wsSheet.Cells[wsSheet.Dimension.Address].AutoFitColumns(); }
public IActionResult PostModelsToExcelDataDictionary() { var httpRequest = HttpContext.Request; HttpResponseMessage response = null; string okResponsText = null; var httpFiles = httpRequest.Form.Files; var httpForms = httpRequest.Form.Keys; var okDictionary = new Dictionary <string, string>(); var ErrorDictionary = new Dictionary <string, string>(); var dmnDataDictionaryModels = new List <DmnDataDictionaryModel>(); var bpmnDataDictionaryModels = new List <BpmnDataDictionaryModel>(); var dataDictionaryModels = new List <DataDictionaryModel>(); if (httpFiles == null && !httpFiles.Any()) { return(NotFound("Can't find any file")); } for (var i = 0; i < httpFiles.Count; i++) { string errorResponsText = null; string errorTemp = string.Empty; var file = httpFiles[i]; tDefinitions dmn = null; var fileExtention = Path.GetExtension(file.FileName); if (fileExtention == ".dmn") { //Deserialize DMN file if (file != null) { using (Stream dmnfile = httpFiles[i].OpenReadStream()) { dmn = new DmnServices().DeserializeStreamDmnFile(dmnfile); } } if (dmn == null) { ErrorDictionary.Add(file.FileName, "Can't validate Shema"); continue; } // check if DMN have desicion table var items = dmn.Items; var decision = items.Where(t => t.GetType() == typeof(tDecision)); var tDrgElements = decision as tDRGElement[] ?? decision.ToArray(); if (!tDrgElements.Any()) { ErrorDictionary.Add(file.FileName, "Dmn file have non decision"); continue; } foreach (tDecision tdecision in decision) { tDecisionTable decisionTable = null; try { DmnServices.GetDecisionsVariables(tdecision, Path.GetFileNameWithoutExtension(file.FileName), ref dmnDataDictionaryModels); } catch { ErrorDictionary.Add(file.FileName, "Can't add serialize info from DMN"); } } } if (fileExtention == ".bpmn") { XDocument bpmnXml = null; try { using (Stream dmnfile = httpFiles[i].OpenReadStream()) { bpmnXml = XDocument.Load(dmnfile); } } catch { ErrorDictionary.Add(file.FileName, "Can't add serialize bpmn to xml"); } if (bpmnXml != null) { try { DmnServices.GetDmnInfoFromBpmnModel(bpmnXml, ref bpmnDataDictionaryModels); } catch { ErrorDictionary.Add(file.FileName, "Can't add serialize bpmn to Data Model Dictionary"); } } } } foreach (var dmnDataInfo in dmnDataDictionaryModels) { var submodel = new BpmnDataDictionaryModel(); try { submodel = bpmnDataDictionaryModels.Single(b => b.DmnId == dmnDataInfo.DmnId); } catch { } dataDictionaryModels.Add(new DataDictionaryModel() { BpmnData = submodel, DmnData = dmnDataInfo }); } // create Excel Package ExcelPackage excelPkg = null; var fileName = "DataDictionaryFromModels"; try { excelPkg = new ExcelPackage(); ExcelWorksheet wsSheet = excelPkg.Workbook.Worksheets.Add("DmnTEK"); var dmnIds = dmnDataDictionaryModels.GroupBy(x => x.DmnId).Select(y => y.First()); var objectPropertyNames = new[] { "DmnId", "DmnNavn", "TekKapitel", "TekLedd", "TekTabell", "TekForskriften", "TekWebLink" }; ExcelServices.CreateDmnExcelTableDataDictionary(dmnIds, wsSheet, "dmnTek", objectPropertyNames); ExcelWorksheet wsSheet1 = excelPkg.Workbook.Worksheets.Add("Variables"); var dmnVariablesIds = dmnDataDictionaryModels.GroupBy(x => x.VariabelId).Select(y => y.First()); var dmnVariablesIdstPropertyNames = new[] { "VariabelId", "VariabelNavn", "VariabelBeskrivelse" }; ExcelServices.CreateDmnExcelTableDataDictionary(dmnVariablesIds, wsSheet1, "Variables", dmnVariablesIdstPropertyNames); ExcelWorksheet wsSheet2 = excelPkg.Workbook.Worksheets.Add("Dmn+Variables"); var objectPropertyNames1 = new[] { "DmnId", "VariabelId", "Type" }; ExcelServices.CreateDmnExcelTableDataDictionary(dmnDataDictionaryModels, wsSheet2, "Dmn+Variables", objectPropertyNames1); ExcelWorksheet wsSheet3 = excelPkg.Workbook.Worksheets.Add("summary"); var summaryPropertyNames = new[] { "DmnData.FilNavn", "BpmnData.BpmnId", "DmnData.DmnId", "DmnData.VariabelId", "DmnData.VariabelType", "DmnData.Type", "DmnData.Kilde" }; ExcelServices.CreateSummaryExcelTableDataDictionary(dataDictionaryModels, wsSheet3, "summary", summaryPropertyNames); } catch { ErrorDictionary.Add("Error", "Can't create Excel file"); } // Save Excel Package try { var path = Path.Combine(@"C:\", "DmnToExcel"); Directory.CreateDirectory(path); excelPkg.SaveAs(new FileInfo(Path.Combine(path, string.Concat(fileName, ".xlsx")))); okDictionary.Add(fileName, "Created in:" + path); } catch { ErrorDictionary.Add(fileName, "Can't be saved"); } if (ErrorDictionary.Any()) { if (okDictionary.Any()) { List <Dictionary <string, string> > dictionaries = new List <Dictionary <string, string> >(); dictionaries.Add(okDictionary); dictionaries.Add(ErrorDictionary); var result = dictionaries.SelectMany(dict => dict) .ToLookup(pair => pair.Key, pair => pair.Value) .ToDictionary(group => group.Key, group => group.First()); return(Ok(result)); } return(BadRequest(ErrorDictionary)); } return(Ok(okDictionary)); }
public IActionResult PosDmnToExcel() { var httpRequest = HttpContext.Request; HttpResponseMessage response = null; string okResponsText = null; var httpFiles = httpRequest.Form.Files; var okDictionary = new Dictionary <string, string>(); var ErrorDictionary = new Dictionary <string, string>(); if (httpFiles == null && !httpFiles.Any()) { return(NotFound("Can't find any file")); } for (var i = 0; i < httpFiles.Count; i++) { string errorResponsText = null; string errorTemp = string.Empty; var file = httpFiles[i]; tDefinitions dmn = null; //Deserialize DMN file if (file != null) { using (Stream dmnfile = httpFiles[i].OpenReadStream()) { dmn = new DmnServices().DeserializeStreamDmnFile(dmnfile); } } if (dmn == null) { ErrorDictionary.Add(file.FileName, "Can't validate Shema"); continue; } // check if DMN have desicion table var items = dmn.Items; var decision = items.Where(t => t.GetType() == typeof(tDecision)); var tDrgElements = decision as tDRGElement[] ?? decision.ToArray(); if (!tDrgElements.Any()) { ErrorDictionary.Add(file.FileName, "Dmn file have non decision"); continue; } // create Excel Package ExcelPackage excelPkg = null; try { excelPkg = new ExcelPackage(); foreach (var tdecision in tDrgElements) { tDecisionTable decisionTable = null; try { var dt = ((tDecision)tdecision).Item; decisionTable = (tDecisionTable)Convert.ChangeType(dt, typeof(tDecisionTable)); ExcelWorksheet wsSheet = excelPkg.Workbook.Worksheets.Add(tdecision.id); //Add Table Title ExcelServices.AddTableTitle(tdecision.name, wsSheet, decisionTable, tdecision.id); // Add "input" and "output" headet to Excel table ExcelServices.AddTableInputOutputTitle(wsSheet, decisionTable); //Add DMN Table to excel Sheet ExcelServices.CreateExcelTableFromDecisionTable(decisionTable, wsSheet, tdecision.id); } catch { ErrorDictionary.Add(file.FileName, string.Concat("Dmn: ", tdecision.name, " Can't be create")); } } } catch { ErrorDictionary.Add(file.FileName, "Can't create Excel file"); continue; } // Save Excel Package try { var filename = Path.GetFileNameWithoutExtension(file.FileName); var path = Path.Combine(@"C:\", "DmnToExcel"); Directory.CreateDirectory(path); excelPkg.SaveAs(new FileInfo(Path.Combine(path, string.Concat(filename, ".xlsx")))); okDictionary.Add(file.FileName, "Created in:" + path); } catch { ErrorDictionary.Add(file.FileName, "Can't be saved"); } } if (ErrorDictionary.Any()) { if (okDictionary.Any()) { List <Dictionary <string, string> > dictionaries = new List <Dictionary <string, string> >(); dictionaries.Add(okDictionary); dictionaries.Add(ErrorDictionary); var result = dictionaries.SelectMany(dict => dict) .ToLookup(pair => pair.Key, pair => pair.Value) .ToDictionary(group => group.Key, group => group.First()); return(Ok(result)); } return(BadRequest(ErrorDictionary)); } return(Ok(okDictionary)); }