public ActionResult <MIDdeconstrutionResponse> MIDCodeDeconstruction([FromBody] MIDCodeDeconstructionRequest model) { ModelStateDictionary ModelState = new ModelStateDictionary(); if (ModelState.IsValid) { try { string xmlString = XmlHelper.ConvertObjectToXML(model); XElement xElement = XElement.Parse(xmlString); MIDdeconstrutionResponse details = _deconstructionService.MIDCodeDeconstruction(xElement.ToString()); if (details != null) { return(Ok(new ApiOkResponse(details))); } else { return(StatusCode(StatusCodes.Status500InternalServerError, new ApiResponse(500, null))); } } catch (Exception ex) { ex.ToString(); return(StatusCode(StatusCodes.Status500InternalServerError, new ApiResponse(500, null))); } } else { return(BadRequest(new ApiBadRequestResponse(ModelState))); } }
private string DeconstructTestCaseResultsResponse(DeconstructTestCase data) { string status = string.Empty; MIDdeconstrutionResponse expectedResult = null; MachineComponentsForMIDdeconstruction machineComponentsForMIDdeconstruction = data.machineComponentsForMIDdeconstruction; MIDCodeDeconstructionRequest midCodeDeconstructionRequest = new MIDCodeDeconstructionRequest(); midCodeDeconstructionRequest.machineComponentsForMIDdeconstruction = machineComponentsForMIDdeconstruction; if (ModelState.IsValid) { expectedResult = data.result; string xmlString = XmlHelper.ConvertObjectToXML(midCodeDeconstructionRequest); XElement xElement = XElement.Parse(xmlString); MIDdeconstrutionResponse actulResult = _deconstructionService.MIDCodeDeconstruction(xElement.ToString()); if (actulResult != null) { CompareLogic compareLogic = new CompareLogic(); ComparisonResult result = compareLogic.Compare(expectedResult, actulResult); if (result.AreEqual) { status = "Passed"; } else { status = "failed"; } } else { status = "Failed"; } } else { status = "Validation Failed"; } return(status); }