Пример #1
0
        public async Task <ResponsePackage> GetBookData(string baseUri, string reqUri, BookTransferModel message)
        {
            ResponsePackage responsePackage = new ResponsePackage();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(baseUri);
                client.DefaultRequestHeaders.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                string requestObject = JsonConvert.SerializeObject(message);
                using (HttpResponseMessage Res = await client.PostAsJsonAsync(reqUri, message))
                {
                    if (Res.IsSuccessStatusCode)
                    {
                        var partnerResponse = Res.Content.ReadAsStringAsync().Result;
                        responsePackage = JsonConvert.DeserializeObject <ResponsePackage>(partnerResponse);
                    }
                    return(responsePackage);
                }
            }
        }
Пример #2
0
        public async Task <IHttpActionResult> BookTransfer(BookTransferModel model)
        {
            var result = await MediatR.SendAsync(model);

            return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, result)));
        }