private string ConstructDescription(Task task, List <TaskTestCase> testcases) { var sb = new StringBuilder(); sb.Append(task.Description); sb.Append("<p><strong>Input:</strong></p>"); sb.Append(task.InputType); sb.Append("<p><strong>Output:</strong></p>"); sb.Append(task.OutputType); sb.Append("<p><strong>Example:</strong></p>"); sb.Append(GenerateTestsTable(testcases)); return(sb.ToString()); }
private TaskDto GetNewTaskDto(Task task, bool individualTask = true) { List <TaskTestCase> testCases = task.TestCases; List <string> inputs = new List <string>(); List <string> outputs = new List <string>(); if (individualTask) { inputs = testCases.Select(x => string.Join("\n", x.Input.DecompressString().Split('\n', '\r').Where(s => s.Length != 0).Select(s => s.Trim('\r', '\n', ' ')))).ToList(); outputs = testCases.Select(x => x.Output.DecompressString()).ToList(); } return(new TaskDto { Id = task.Id, Name = task.Name, Description = individualTask ? ConstructDescription(task, testCases) : null, Value = task.Value, Inputs = inputs, Outputs = outputs, InputType = task.InputType }); }