コード例 #1
0
        internal async void SaveClerk()
        {
            using (HttpClient httpClient = new HttpClient())
            {
                var api      = new ApiService <Clerk>(httpClient);
                var response = await api.PutEntityAsync(_clerk.GetToken(), _clerk.ToJson());

                if (response.IsSuccessStatusCode)
                {
                    _clerk.Syncronized = true;
                    MessagingCenter.Send <Clerk>(_clerk, SUCCESS);
                }
                else
                {
                    var content = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
                    if (response.Content != null)
                    {
                        response.Content.Dispose();
                    }

                    MessagingCenter.Send(new SimpleHttpResponseException(response.StatusCode, response.ReasonPhrase, content),
                                         FAIL);
                }
            }
        }