예제 #1
0
        public UpdatePatientSystemDataResponse Put(UpdatePatientSystemDataRequest request)
        {
            UpdatePatientSystemDataResponse response = new UpdatePatientSystemDataResponse();

            try
            {
                RequireUserId(request);
                response.Success = Manager.UpdatePatientSystem(request);
                response.Version = request.Version;
            }
            catch (Exception ex)
            {
                RaiseException(response, ex);
            }
            return(response);
        }
예제 #2
0
파일: Importer.cs 프로젝트: rotovibe/engage
        public UpdatePatientSystemDataResponse UpdatePatientSystem(UpdatePatientSystemDataRequest request)
        {
            //[Route("/{Context}/{Version}/{ContractNumber}/Patient/{PatientId}/PatientSystem/{Id}", "PUT")]
            Uri updateUri = new Uri(string.Format("{0}/PatientSystem/{1}/{2}/{3}/Patient/{4}/PatientSystem/{5}?UserId={6}",
                                                  Url,
                                                  Context,
                                                  Version,
                                                  ContractNumber,
                                                  request.PatientId,
                                                  request.Id,
                                                  HeaderUserId));
            HttpClient updateClient = GetHttpClient(updateUri);

            UpdatePatientSystemDataResponse response = null;

            DataContractJsonSerializer updateJsonSer = new DataContractJsonSerializer(typeof(UpdatePatientSystemDataRequest));

            // use the serializer to write the object to a MemoryStream
            MemoryStream updateMs = new MemoryStream();

            updateJsonSer.WriteObject(updateMs, request);
            updateMs.Position = 0;


            //use a Stream reader to construct the StringContent (Json)
            StreamReader updateSr = new StreamReader(updateMs);

            StringContent updateContent = new StringContent(updateSr.ReadToEnd(), System.Text.Encoding.UTF8, "application/json");

            updateMs.Dispose();

            //Post the data
            var updateResponse        = updateClient.PutAsync(updateUri, updateContent);
            var updateResponseContent = updateResponse.Result.Content;

            string updateResponseString = updateResponseContent.ReadAsStringAsync().Result;


            using (var updateMsResponse = new MemoryStream(Encoding.Unicode.GetBytes(updateResponseString)))
            {
                var updateSerializer = new DataContractJsonSerializer(typeof(UpdatePatientSystemDataResponse));
                response = (UpdatePatientSystemDataResponse)updateSerializer.ReadObject(updateMsResponse);
            }

            return(response);
        }