public GetContactByPatientIdDataResponse GetContactByPatientId(string patientId) { //[Route("/Contact/{Context}/{Version}/{ContractNumber}/Patient/{PatientId}/Contact", "GET")] Uri getContactUri = new Uri(string.Format("{0}/Contact/{1}/{2}/{3}/Patient/{4}/Contact?UserId={5}", Url, Context, Version, ContractNumber, patientId, HeaderUserId )); HttpClient getContactClient = GetHttpClient(getContactUri); GetContactByPatientIdDataRequest getContactRequest = new GetContactByPatientIdDataRequest { PatientId = patientId, Context = Context, Version = Version, ContractNumber = ContractNumber }; DataContractJsonSerializer getContactJsonSer = new DataContractJsonSerializer(typeof(GetContactByPatientIdDataRequest)); MemoryStream getContactMs = new MemoryStream(); getContactJsonSer.WriteObject(getContactMs, getContactRequest); getContactMs.Position = 0; //use a Stream reader to construct the StringContent (Json) StreamReader getContactSr = new StreamReader(getContactMs); StringContent getContactContent = new StringContent(getContactSr.ReadToEnd(), System.Text.Encoding.UTF8, "application/json"); getContactMs.Dispose(); //Post the data var getContactResponse = getContactClient.GetStringAsync(getContactUri); var getContactResponseContent = getContactResponse.Result; string getContactResponseString = getContactResponseContent; GetContactByPatientIdDataResponse responseContact = null; using (var getContactMsResponse = new MemoryStream(Encoding.Unicode.GetBytes(getContactResponseString))) { var getContactSerializer = new DataContractJsonSerializer(typeof(GetContactByPatientIdDataResponse)); responseContact = (GetContactByPatientIdDataResponse)getContactSerializer.ReadObject(getContactMsResponse); } return(responseContact); }
public GetContactByPatientIdDataResponse Get(GetContactByPatientIdDataRequest request) { GetContactByPatientIdDataResponse response = new GetContactByPatientIdDataResponse(); response.Version = request.Version; try { if (string.IsNullOrEmpty(request.UserId)) { throw new UnauthorizedAccessException("ContactDD:Get()::Unauthorized Access"); } response.Contact = Manager.GetContactByPatientId(request); } catch (Exception ex) { CommonFormat.FormatExceptionResponse(response, base.Response, ex); string aseProcessID = ConfigurationManager.AppSettings.Get("ASEProcessID") ?? "0"; Helpers.LogException(int.Parse(aseProcessID), ex); } return(response); }