예제 #1
0
 private void search()
 {
     if (searchString == null || searchString == "")
     {
         students.Clear();
         foreach (var s in Students)
         {
             StudentCell cell = new StudentCell(s);
             cell.textColour = Application.Current.Resources["OnSurface"] as Color? ?? Color.Black;
             students.Add(cell);
         }
     }
     else
     {
         string searchStringTemp             = searchString.ToLower();
         List <Models.Student> searchResults = Students.Where <Models.Student>(s => $"{s.Forename.ToLower()} {s.Surname.ToLower()}".StartsWith(searchStringTemp) || s.Forename.ToLower().StartsWith(searchStringTemp) || s.Surname.ToLower().StartsWith(searchStringTemp) || s.SwimEnglandNumber.StartsWith(searchStringTemp)).ToList();
         students.Clear();
         foreach (var s in searchResults)
         {
             StudentCell cell = new StudentCell(s);
             cell.textColour = Application.Current.Resources["OnSurface"] as Color? ?? Color.Black;
             students.Add(cell);
         }
     }
 }
예제 #2
0
 public static Models.Student ConvertToStudent(StudentCell cell)
 {
     return(new Models.Student()
     {
         Forename = cell.Forename,
         Surname = cell.Surname,
         SwimEnglandNumber = cell.SwimEnglandNumber,
         MedicalDetails = cell.MedicalDetails,
         DateOfBirth = cell.DateOfBirth,
         CurrentGradeNumber = cell.CurrentGradeNumber
     });
 }
예제 #3
0
        private void selectStudent(object obj)
        {
            StudentCell currentCell = obj as StudentCell;

            currentCell.textColour = Application.Current.Resources["OnSecondary"] as Color? ?? Color.Black;
            List <StudentCell> temp = students.Except <StudentCell>(new List <StudentCell>()
            {
                currentCell
            }).ToList();

            foreach (var a in temp)
            {
                a.textColour = Application.Current.Resources["OnSurface"] as Color? ?? Color.Black;
            }

            Shell.Current.Navigation.PushAsync(new Views.StudentDetailPage(StudentCell.ConvertToStudent(currentCell)));
        }
예제 #4
0
        private void loadData()
        {
            isRefreshing = true;
            Models.AllStudentsResponse        resp;
            Task <Models.AllStudentsResponse> task = Task.Run(() => restService.GetAllStudentsAsync());

            task.ContinueWith(t => Device.BeginInvokeOnMainThread(
                                  async() =>
            {
                if (t.IsFaulted)
                {
                    await App.Current.MainPage.DisplayAlert("Connection error", "There was an error connecting to the server", "Try Again");
                }
                resp = t.Result;
                if (!resp.Success)
                {
                    isRefreshing = false;
                    await App.Current.MainPage.DisplayAlert(resp.Error.Message, resp.Error.Detail, "Try again");
                    return;
                }
                Students = resp.Students.values;

                students.Clear();



                foreach (var s in Students)
                {
                    StudentCell cell = new StudentCell(s);
                    cell.textColour  = Application.Current.Resources["OnSurface"] as Color? ?? Color.Black;
                    students.Add(cell);
                }
                isRefreshing = false;
                search();
            }
                                  ));
        }