Пример #1
0
        public async void sucess(string result)
        {
            UpdateLeavetype = new UpdateLeavetype();
            await App.Current.MainPage.DisplayAlert("HMS", result, "OK");

            OnPropertyChanged("UpdateLeavetype");
        }
Пример #2
0
        public async void UpdateLeavetype(UpdateLeavetype updateLeavetype)
        {
            CourseResponse      courseResponse;
            CourseErrorResponse courseErrorResponse;

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

                string jsn = JsonConvert.SerializeObject(updateLeavetype);

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

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

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

                    courseResponse = JsonConvert.DeserializeObject <CourseResponse>(resultHostel);
                    editleaveType.sucess(courseResponse.message);
                }
                else
                {
                    UserDialogs.Instance.HideLoading();
                    string resultHostel = await response.Content.ReadAsStringAsync();

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