private void UpdateAllFilters()
 {
     // This is to make sure that the app got the study groups that is used as search filters. 
     DbLocation dbLocation = new DbLocation();
     StudyGroupsController sgc = new StudyGroupsController();
     LocationsController lc = new LocationsController();
     JobTypesController jtc = new JobTypesController();
     CoursesController cc = new CoursesController();
     if (dbLocation.GetAllLocations().Count != 0)
     {           
         lc.CompareServerHash();
         sgc.CompareServerHash();
         jtc.CompareServerHash();
         cc.CompareServerHash();
     }
     else
     {
         cc.UpdateCoursesFromServer();
         jtc.UpdateJobTypesFromServer();
         sgc.UpdateStudyGroupsFromServer();
         lc.UpdateLocationsFromServer();
     }
     
 }
        private async void GetAllFilters(object sender, EventArgs e)
        {
            DbLocation lc = new DbLocation();
            DbCourse cc = new DbCourse();
            DbStudyGroup sgc = new DbStudyGroup();
            DbJobType jtc = new DbJobType();
            List<Location> locationsFilter = lc.GetAllLocations();
            List<Course> coursesFilter = cc.GetAllCourses();
            List<StudyGroup> studyGroupsFilter = sgc.GetAllStudyGroups();
            List<JobType> jobTypesJobFilter = jtc.GetJobTypeFilterJob();
            List<JobType> jobTypesProjectFilter = jtc.GetJobTypeFilterProject();

            System.Diagnostics.Debug.WriteLine("GetAllFilters: locationsFilter.Count: " + locationsFilter.Count);
            System.Diagnostics.Debug.WriteLine("GetAllFilters: coursesFilter.Count: " + coursesFilter.Count);
            System.Diagnostics.Debug.WriteLine("GetAllFilters: studyGroupsFilter.Count: " + studyGroupsFilter.Count);
            System.Diagnostics.Debug.WriteLine("GetAllFilters: jobTypesJobFilter.Count: " + jobTypesJobFilter.Count);
            System.Diagnostics.Debug.WriteLine("GetAllFilters: jobTypesProjectFilter.Count: " +
                                               jobTypesProjectFilter.Count);
        }
 /// <summary>
 /// Activate this method when a login is successful to navigate to a MainPage and remove the 
 /// Former pages for the Navigation.
 /// It will also update all the search filter for the app, and its crucial that they are in this 
 /// method and not just the startup method.
 /// </summary>
 public static void SuccessfulLoginAction()
 {
     // NavPage.Navigation.PopModalAsync();
     DbLocation dbLocation = new DbLocation();
     StudyGroupsController sgc = new StudyGroupsController();
     LocationsController lc = new LocationsController();
     JobTypesController jtc = new JobTypesController();
     CoursesController cc = new CoursesController();
     NavPage.Navigation.InsertPageBefore(new MainPage(), NavPage.Navigation.NavigationStack.First());
     NavPage.Navigation.PopToRootAsync();
     
     if (dbLocation.GetAllLocations().Count != 0)
     {
         lc.CompareServerHash();
         sgc.CompareServerHash();
         jtc.CompareServerHash();
         cc.CompareServerHash();
     }
     else
     {
         cc.UpdateCoursesFromServer();
         jtc.UpdateJobTypesFromServer();
         sgc.UpdateStudyGroupsFromServer();
         lc.UpdateLocationsFromServer();
     }
     
 }
 private string CreateLocalHash()
 {
     DbLocation db = new DbLocation();
     List<Location> locations = db.GetAllLocations();
     StringBuilder sb = new StringBuilder();
     foreach (var loc in locations)
     {
         sb.Append(Hasher.Base64Decode(loc.id));
     }
     return Hasher.CalculateMd5Hash(sb.ToString());
 }