protected override async void OnAppearing() { if (App.CheckConnection()) { if (await App.userExists(App.UserUID)) { busyindicator.IsVisible = true; bool connection = true; List <EventModel> allEvents = new List <EventModel>(); List <EventModel> listEvents = new List <EventModel>(); try { await fireBaseHelperStudent.AddGPA(userID); user = await fireBaseHelperStudent.GetStudent(userID); allEvents = await fireBaseHelperCalendar.GetAllEvents(); listEvents = next7DaysEvents(allEvents); } catch (Exception) { connection = false; } if (connection) { // creating a new model from 2 classes - student and calendar StudentCalendar studentCalendar = new StudentCalendar(user, listEvents); this.BindingContext = studentCalendar; // progress bar totalGPA.Progress = Convert.ToDouble(user.FinalGPA); busyindicator.IsVisible = false; } else { await Navigation.PushAsync(new NoInternetConnectionPage("noApp")); } } else { await DisplayAlert("Something went wrong...", "", "OK"); App.Current.MainPage = new NavigationPage(new LogIn()); } } else { await Navigation.PushAsync(new NoInternetConnectionPage("noApp")); } }
protected override async void OnAppearing() { await fireBaseHelperStudent.AddGPA(userID); user = await fireBaseHelperStudent.GetStudent(userID); List <EventModel> allEvents = await fireBaseHelperCalendar.GetAllEvents(); List <EventModel> listEvents = next7DaysEvents(allEvents); // creating a new model from 2 classes - student and calendar StudentCalendar studentCalendar = new StudentCalendar(user, listEvents); this.BindingContext = studentCalendar; // progress bar totalGPA.Progress = Convert.ToDouble(user.FinalGPA); }
public async Task <StudentCalendar> GetStudentCalendar(int studentUsi) { StudentAttendance studentAttendance = await _studentAtttendanceRepository.GetStudentAttendanceAsync(studentUsi); var descriptors = _customParametersProvider.GetParameters().descriptors; var days = await _studentRepository.GetStudentCalendarDays(studentUsi); var calendar = new StudentCalendar(); calendar.InstructionalDays = days.Where(x => x.Event.Description.Contains(descriptors.instructionalDayDescriptorCodeValue)).ToList(); calendar.NonInstructionalDays = days.Where(x => x.Event.Description.Contains(descriptors.nonInstrunctionalDayDescriptorCodeValue)).ToList(); calendar.Holidays = days.Where(x => x.Event.Description.Contains(descriptors.holiDayDescriptorCodeValue)).ToList(); calendar.TeacherOnlyDays = days.Where(x => x.Event.Description.Contains(descriptors.teacherOnlyDayDescriptorCodeValue)).ToList(); calendar.AttendanceEventDays = new List <StudentCalendarDay>(); calendar.AttendanceEventDays.AddRange(studentAttendance.ExcusedAttendanceEvents.Select(x => new StudentCalendarDay { Date = x.DateOfEvent, Event = new StudentCalendarEvent { Name = x.EventCategory, Description = string.Format("{0}{1}", x.EventDescription, x.Reason != null ? ": " + x.Reason : "") } }).ToList()); calendar.AttendanceEventDays.AddRange(studentAttendance.UnexcusedAttendanceEvents.Select(x => new StudentCalendarDay { Date = x.DateOfEvent, Event = new StudentCalendarEvent { Name = x.EventCategory, Description = x.EventDescription } }).ToList()); calendar.AttendanceEventDays.AddRange(studentAttendance.TardyAttendanceEvents.Select(x => new StudentCalendarDay { Date = x.DateOfEvent, Event = new StudentCalendarEvent { Name = x.EventCategory, Description = x.EventDescription } }).ToList()); return(calendar); }