Ejemplo n.º 1
0
        public async void updatesucessfully(string result)
        {
            UpdateWarden = new UpdateWarden();
            await App.Current.MainPage.DisplayAlert("HMS", result, "OK");

            OnPropertyChanged("UpdateWarden");
        }
Ejemplo n.º 2
0
        public async void UpdateWardenDetail(UpdateWarden updateWarden)
        {
            UpdateWardenResponse      updateWardenResponse;
            UpdateWardenErrorResponse updateWardenErrorResponse;

            try
            {
                UserDialogs.Instance.ShowLoading();
                var client = new HttpClient();
                client.BaseAddress = new Uri(ApplicationURL.BaseURL);

                string jsn = JsonConvert.SerializeObject(updateWarden);

                var content = new StringContent(jsn, Encoding.UTF8, "application/json");

                HttpResponseMessage response = await client.PostAsync(ApplicationURL.EditWarenDetail, content);

                if ((int)response.StatusCode == 200)
                {
                    UserDialogs.Instance.HideLoading();
                    string resultHostel = await response.Content.ReadAsStringAsync();

                    updateWardenResponse = JsonConvert.DeserializeObject <UpdateWardenResponse>(resultHostel);
                    editWardenDetail.updatesucessfully(updateWardenResponse.message);
                }
                else
                {
                    UserDialogs.Instance.HideLoading();
                    string resultHostel = await response.Content.ReadAsStringAsync();

                    updateWardenErrorResponse = JsonConvert.DeserializeObject <UpdateWardenErrorResponse>(resultHostel);
                    editWardenDetail.servicefailed(updateWardenErrorResponse.errors[0].message);
                }
            }
            catch (Exception ex)
            {
                UserDialogs.Instance.HideLoading();
                await App.Current.MainPage.DisplayAlert("HMS", ex.ToString(), "OK");
            }
        }