Ejemplo n.º 1
0
        async Task GetStudents()
        {
            try
            {
                this.IsRefreshing = true;

                var connection = await studentService.CheckConnection();

                if (!connection)
                {
                    this.IsRefreshing = false;
                    await Application.Current.MainPage.DisplayAlert("Error", "No internet connection", "Cancel");

                    return;
                }
                var listStudents = (await studentService.GetAll(Endpoints.GET_STUDENTS)).Select(x => ToStudentItemViewModel(x));
                this.AllStudents  = listStudents.ToList();
                this.Students     = new ObservableCollection <StudentItemViewModel>(listStudents);
                this.IsRefreshing = false;
            }
            catch (Exception ex)
            {
                this.IsRefreshing = false;
                await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "Cancel");
            }
        }
Ejemplo n.º 2
0
        async Task GetStudentsByCourse()
        {
            try
            {
                this.IsRefreshing = true;

                var connection = await studentService.CheckConnection();

                if (!connection)
                {
                    this.IsRefreshing = false;
                    await Application.Current.MainPage.DisplayAlert("Error", "No internet connection", "Cancel");

                    return;
                }

                var listStudents = (await studentService.GetAll(Endpoints.GET_STUDENTS_BY_COURSE + this.course.CourseID)).OrderByDescending(x => x.ID);
                this.Students     = new ObservableCollection <StudentDTO>(listStudents);
                this.IsRefreshing = false;
            }
            catch (Exception ex)
            {
                this.IsRefreshing = false;
                await Application.Current.MainPage.DisplayAlert("Error", ex.Message, "Cancel");
            }
        }