public ActionResult <MIDCodeDetails> GenerateCodes([FromBody] MIDCodeCreatorRequest model) { ModelStateDictionary ModelState = new ModelStateDictionary(); ValidationHelper.ValidateInput(ref ModelState, ref model); if (ModelState.IsValid) { try { string xmlString = XmlHelper.ConvertObjectToXML(model); XElement xElement = XElement.Parse(xmlString); MIDCodeDetails details = _service.GenerareMIDCodes(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 GenerateCodeTestCaseResultsResponse(TestCase data) { string status = string.Empty; MIDCodeDetails expectedResult = null; MachineComponentsForMIDgeneration machineComponentsForMIDgeneration = data.machineComponentsForMIDgeneration; MIDCodeCreatorRequest mIDCodeCreatorRequest = new MIDCodeCreatorRequest(); mIDCodeCreatorRequest.machineComponentsForMIDgeneration = machineComponentsForMIDgeneration; ModelStateDictionary ModelState = new ModelStateDictionary(); ValidationHelper.ValidateInput(ref ModelState, ref mIDCodeCreatorRequest); if (ModelState.IsValid) { expectedResult = data.result; string xmlString = XmlHelper.ConvertObjectToXML(mIDCodeCreatorRequest); XElement xElement = XElement.Parse(xmlString); MIDCodeDetails actualResult = _service.GenerareMIDCodes(xElement.ToString()); if (actualResult != null) { CompareLogic compareLogic = new CompareLogic(); compareLogic.Config.IgnoreProperty <Row>(x => x._faultcode); ComparisonResult result = compareLogic.Compare(expectedResult, actualResult); if (result.AreEqual) { status = "Passed"; } else { status = "failed"; } } else { status = "Failed"; } } else { status = "Validation Failed"; } return(status); }