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

            OnPropertyChanged("UpdatePassword");
            OnPropertyChanged("Cnfpassword");
        }
Ejemplo n.º 2
0
        public async void UpdateStudentPassword(UpdateStudPassword updateStudPassword)
        {
            UpdateStudPasswordResponse updateStudPasswordResponse;
            UpdateStudErrorResponse    updateStudErrorResponse;

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

                string jsn = JsonConvert.SerializeObject(updateStudPassword);

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

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

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

                    updateStudPasswordResponse = JsonConvert.DeserializeObject <UpdateStudPasswordResponse>(resultHostel);
                    iupdatestudentpassword.UpdatedSucessfully(updateStudPasswordResponse.message);
                }
                else
                {
                    UserDialogs.Instance.HideLoading();
                    string resultHostel = await response.Content.ReadAsStringAsync();

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