예제 #1
0
 public static Models.Class ConvertToClass(ClassesTemp temp)
 {
     return(new Models.Class()
     {
         ID = temp.ID,
         Pool = temp.Pool,
         coach = temp.coach,
         ClassGrade = temp.ClassGrade,
         TimeOfClass = temp.TimeOfClass,
         Attendance = temp.Attendance,
         Students = temp.Students
     });
 }
예제 #2
0
        private void loadData()
        {
            isRefreshing = true;
            Models.AllClassResponse        resp;
            Task <Models.AllClassResponse> task = Task.Run(() => restService.GetAllClasses());

            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;
                }

                if (resp.Classes == null || resp.Classes.length == 0 || resp.Classes.values == null)
                {
                    isRefreshing = false; return;
                }

                Classes = resp.Classes.values;


                classes.Clear();



                foreach (var c in Classes)
                {
                    ClassesTemp ct = new ClassesTemp(c);
                    classes.Add(ct);
                }
                isRefreshing = false;
            }
                                  ));
        }