Пример #1
0
        private async Task <IQueryResult <T> > PostAsync <T>(IQueryRequest queryRequest)
        {
            var queryResult = new QueryResult <T>();
            var content     = new FormUrlEncodedContent(queryRequest.GetFormValues());

            try
            {
                var request = await HttpClient.PostAsync(queryRequest.GetBaseUri(), content);

                using (var response = await request.Content.ReadAsStreamAsync())
                {
                    queryResult         = DataMapper.Map <QueryResult <T> >(response);
                    queryResult.Success = queryResult.Status == QueryStatus.Success;
                }
            }
            catch (AggregateException ae)
            {
                ae.Flatten().Handle(e =>
                {
                    Log.Error(e);
                    ProcessError(e, queryResult);
                    return(true);
                });
            }
            return(queryResult);
        }