public static Models.Grade ConvertToGrade(GradeCell cell) { return(new Models.Grade() { ID = cell.ID, Number = cell.Number, Students = cell.Students, Tests = cell.Tests, }); }
private void selectGrade(object obj) { GradeCell g = (GradeCell)obj; g.textColour = Application.Current.Resources["OnSecondary"] as Color? ?? Color.Black; List <GradeCell> temp = gradesCollection.Except <GradeCell>(new List <GradeCell>() { g }).ToList(); foreach (var a in temp) { a.textColour = Application.Current.Resources["OnSurface"] as Color? ?? Color.Black; } Shell.Current.Navigation.PushAsync(new Views.GradeDetailPage(GradeCell.ConvertToGrade(g))); }
private void loadData() { isRefreshing = true; Models.AllGradesResponse resp; Task <Models.AllGradesResponse> task = Task.Run(() => restService.GetAllGradesAsync()); 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; } grades = resp.Grades.values; gradesCollection.Clear(); foreach (var g in grades) { GradeCell newG = new GradeCell(g); newG.textColour = Application.Current.Resources["OnSurface"] as Color? ?? Color.Black; gradesCollection.Add(newG); } isRefreshing = false; } )); }