public async Task <IActionResult> Queue() { var content = new Dictionary <string, string>(); try { content = await Request.BodyAsDictionaryAsync(); } catch { return(Ok()); } if (content["ConnectionType"] == "GetRequest" && content["ID"] == printerKey) { IEnumerable <PrintQueue> queue = _printer.GetQueue(); if (queue.Any()) { var printjob = $"<?xml version=\"1.0\" encoding=\"utf-8\"?><PrintRequestInfo>{string.Concat(queue.Select(x => x.Message))}</PrintRequestInfo>".Trim(); _printer.SubmitQueue(queue); return(Ok(printjob)); } } if (content["ConnectionType"] == "SetResponse" && content["ID"] == printerKey) { XmlDocument responseFile = new XmlDocument(); responseFile.LoadXml(content["ResponseFile"]); string success = responseFile.SelectSingleNode("PrintResponseInfo")?.FirstChild?.Attributes["success"]?.Value; switch (success) { case "true": _printer.ClearQueue(); break; case "false": var error = responseFile.SelectSingleNode("PrintResponseInfo").FirstChild.Attributes["code"].Value; try { throw new Exception(error); } catch { } break; default: break; } } return(Ok()); }