public async void Disciplinaryactiontaken(string result)
        {
            DisciplinaryActionbywarden = new DisciplinaryActionbywarden();
            await App.Current.MainPage.DisplayAlert("HMS", result, "OK");

            OnPropertyChanged("DisciplinaryActionbywarden");
        }
Esempio n. 2
0
        public async void SaveDisciplinaryActionTaken(DisciplinaryActionbywarden disciplinaryActionbywarden)
        {
            string              resultHostel;
            WardenResponse      wardenResponse;
            Wardenerrorresponse wardenerrorresponse;

            try
            {
                UserDialogs.Instance.ShowLoading();
                var client = new HttpClient();
                client.BaseAddress = new Uri(ApplicationURL.BaseURL);
                string json    = JsonConvert.SerializeObject(disciplinaryActionbywarden);
                var    content = new StringContent(json, Encoding.UTF8, "application/json");
                HttpResponseMessage response = await client.PostAsync(ApplicationURL.Disciplinaryaction, content);

                resultHostel = await response.Content.ReadAsStringAsync();

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

                    wardenResponse = JsonConvert.DeserializeObject <WardenResponse>(resultHostel);
                    disciplinaryAction.Disciplinaryactiontaken(wardenResponse.message);
                }
                else
                {
                    UserDialogs.Instance.HideLoading();
                    resultHostel = await response.Content.ReadAsStringAsync();

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