Ejemplo n.º 1
0
            private Task <FluentResponse <T, TError> > BuildResponse <T>(HttpResponseMessage response)
            {
                if (response.IsSuccessStatusCode)
                {
                    return(response.Content.ReadAsAsync <T>().ContinueWith(t =>
                    {
                        var result = new FluentResponse <T, TError>();

                        result.Entity = t.Result;

                        result.StatusCode = response.StatusCode;

                        return result;
                    }));
                }

                return(response.Content.ReadAsAsync <TError>().ContinueWith(t =>
                {
                    var result = new FluentResponse <T, TError>();

                    result.Error = t.Result;

                    result.StatusCode = response.StatusCode;

                    return result;
                }));
            }
Ejemplo n.º 2
0
            private async Task <FluentResponse <T, TError> > BuildResponse <T>(HttpResponseMessage response)
            {
                var result = new FluentResponse <T, TError>();

                if (response.IsSuccessStatusCode)
                {
                    result.Entity = await response.Content.ReadAsAsync <T>();
                }
                else
                {
                    result.Error = await response.Content.ReadAsAsync <TError>();
                }

                result.StatusCode = response.StatusCode;

                return(result);
            }