internal async void DeleteRecord(StudentInfo ab)
        {
            if (Plugin.Connectivity.CrossConnectivity.Current.IsConnected)
            {
                UserDialogs.Instance.ShowLoading("Loading Data", MaskType.Clear);
                try
                {
                    var        authHeader = new AuthenticationHeaderValue("bearer", AppConstants.BearerToken);
                    HttpClient client     = new HttpClient();
                    client.DefaultRequestHeaders.Authorization = authHeader;
                    var URL = "https://developer.fusionstak.com/demoapp/api/user/" + ab.id;
                    HttpClientHandler   clientHandler = new HttpClientHandler();
                    HttpRequestMessage  request       = new HttpRequestMessage();
                    HttpResponseMessage response      = await client.DeleteAsync(URL);

                    var result = await response.Content.ReadAsStringAsync();

                    var response1 = JsonConvert.DeserializeObject <ResponseModel>(result);
                    UserDialogs.Instance.HideLoading();
                    if (response1 != null)
                    {
                        if (response1.success)
                        {
                            await PageDialogService.DisplayAlertAsync("", "Deleted Successfully", "OK");

                            AllStudentsList.Remove(ab);
                        }
                        else
                        {
                            await PageDialogService.DisplayAlertAsync("Error!!!", "Please try again...!!", "OK");
                        }
                    }
                    else
                    {
                        await PageDialogService.DisplayAlertAsync("Error!!!", "Please try again...!!", "OK");
                    }
                }
                catch (Exception e)
                {
                    await PageDialogService.DisplayAlertAsync("Error!!!", "Please try again...!!", "OK" + e);
                }
                finally
                {
                    UserDialogs.Instance.HideLoading();
                }
            }
            else
            {
                UserDialogs.Instance.HideLoading();
                await PageDialogService.DisplayAlertAsync("", "You are not connected to the internet, Please check your connectivity and try again.", "OK");

                return;
            }
        }
Example #2
0
 public CourseAttandee FindStudentByID(int searchedID)
 {
     return(AllStudentsList.Find(x => x.UniqueIdetifier == searchedID));
 }