예제 #1
0
        public async Task <Models.Output> SaveOutput(Models.Output output)
        {
            var    _output = output;
            string url     = "http://" + PATHSERVER + "/tshirt/output/save";

            try
            {
                string json    = JsonConvert.SerializeObject(output);
                var    content = new StringContent(json, Encoding.UTF8, "application/json");

                Debug.WriteLine(json);

                HttpResponseMessage result = null;

                result = await client.PostAsync(url, content);

                if (result.IsSuccessStatusCode)
                {
                    var x = await result.Content.ReadAsStringAsync();

                    _output.Id = JsonConvert.DeserializeObject <int>(x);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(@"				ERROR {0}", ex.Message);
            }
            return(_output);
        }
예제 #2
0
        public async Task <Models.Output> Get(int id)
        {
            Models.Output output = null;
            string        url    = "http://" + PATHSERVER + "/tshirt/output/Get";
            string        _id    = "?id=" + id;
            string        uri    = string.Concat(url, _id);

            try
            {
                HttpResponseMessage result = null;

                result = await client.GetAsync(uri);

                if (result.IsSuccessStatusCode)
                {
                    var x = await result.Content.ReadAsStringAsync();

                    output = JsonConvert.DeserializeObject <Models.Output>(x);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(@"				ERROR {0}", ex.Message);
            }
            return(output);
        }