public void sucess(string result) { AssignServiceModel = new AssignServiceModel(); txtpersonname.Text = ""; txtjobtitle.Text = ""; txtpersonphoneno.Text = ""; DisplayAlert("HMS", result, "OK"); Navigation.PopPopupAsync(true); }
public async void AssignServiceToPerson(AssignServiceModel assignServiceModel, string requestTypeId, string userId) { UpdateAreaResponse updateAreaResponse; UpdateAreaErrorResponse updateAreaErrorResponse; HttpResponseMessage response; try { UserDialogs.Instance.ShowLoading(); var client = new HttpClient(); UserDialogs.Instance.ShowLoading(); client.BaseAddress = new Uri(ApplicationURL.BaseURL); client.DefaultRequestHeaders.Add("requestTypeId", requestTypeId); client.DefaultRequestHeaders.Add("userId", userId); string json = JsonConvert.SerializeObject(assignServiceModel); var content = new StringContent(json, Encoding.UTF8, "application/json"); response = await client.PostAsync(ApplicationURL.Assignserviceperson, content); if ((int)response.StatusCode == 200) { UserDialogs.Instance.HideLoading(); string result = await response.Content.ReadAsStringAsync(); updateAreaResponse = JsonConvert.DeserializeObject <UpdateAreaResponse>(result); iassignserviceperson.sucess(updateAreaResponse.message); } else { UserDialogs.Instance.HideLoading(); string result = await response.Content.ReadAsStringAsync(); updateAreaErrorResponse = JsonConvert.DeserializeObject <UpdateAreaErrorResponse>(result); iassignserviceperson.failer(updateAreaErrorResponse.errors[0].message); } } catch (Exception ex) { UserDialogs.Instance.HideLoading(); await App.Current.MainPage.DisplayAlert("HMS", "Something went wrong.", "OK"); } }