Пример #1
0
        public async Task <ValueOrError <T> > Post <T>(string uri, T data)
        {
            if (string.IsNullOrEmpty(uri))
            {
                return(ValueOrError <T> .CreateFromError("Empty Uri"));
            }

            var json = JsonConvert.SerializeObject(data);
            var res  = await _server.Post(uri, json);

            if (res.IsError)
            {
                return(ValueOrError <T> .CreateFromError(res.ErrorMessage));
            }

            data = JsonConvert.DeserializeObject <T>(res.Value);
            return(ValueOrError <T> .CreateFromValue(data));
        }