Beispiel #1
0
        /// <summary>
        /// add new order of existing patient.
        /// </summary>
        /// <param name="body"> OrderBody object that has list of Orders</param>
        /// <returns> Response object with status code and message</returns>
        public async Task <Response> ManageOrder(OrderBody body)
        {
            Response jsonObj;

            try
            {
                Client.DefaultRequestHeaders.Clear();
                Client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "application/json;");
                var auth = GetToken();
                Client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", "Bearer " + auth.Result.access_token);
                var Content     = JsonConvert.SerializeObject(body);
                var buffer      = System.Text.Encoding.UTF8.GetBytes(Content);
                var byteContent = new ByteArrayContent(buffer);
                using (HttpResponseMessage response = await Client.PostAsync("http://104.155.18.156/aggregator/api/web/v1/manage-orders/manage", byteContent))
                {
                    string responseBody = response.Content.ReadAsStringAsync().Result;
                    jsonObj = JsonConvert.DeserializeObject <Response>(responseBody);
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(jsonObj);
        }
Beispiel #2
0
        /// <summary>
        /// add new order of existing patient.
        /// </summary>
        /// <param name="body"> OrderBody object that has list of Orders</param>
        /// <returns> Response object with status code and message</returns>
        public static async Task <Response> ManageOrder(OrderBody body)
        {
            Response jsonObj;

            try
            {
                var Content     = JsonConvert.SerializeObject(body);
                var buffer      = System.Text.Encoding.UTF8.GetBytes(Content);
                var byteContent = new ByteArrayContent(buffer);
                using (HttpResponseMessage response = await Client.PostAsync("http://104.155.18.156/aggregator/api/web/v1/manage-orders/manage", byteContent))
                {
                    string responseBody = response.Content.ReadAsStringAsync().Result;
                    jsonObj = JsonConvert.DeserializeObject <Response>(responseBody);
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(jsonObj);
        }