public ActionResult AddDriverDetails(DriverDetails model) { long id = 0; ModelStateDictionary ModelState = new ModelStateDictionary(); DriverValidationHelper.ValidateDriverInput(ref ModelState, ref model); if (ModelState.IsValid) { try { string xmlString = XmlHelper.ConvertObjectToXML(model); XElement xElement = XElement.Parse(xmlString); bool isExist = _service.CheckIsDriverDetailsExist(xmlString); if (isExist == true) { return(StatusCode(StatusCodes.Status409Conflict, new ApiResponse(404, Constants.recordExist))); } else { id = _service.AddOrUpdateDriverDetails(xElement.ToString()); if (id > 0) { return(Ok(new ApiOkResponse(id, Constants.recordSaved))); } 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))); } }