Beispiel #1
0
        public CourseViewModel(string courseCode, PinnedCourses pinnedCourses)
        {
            Code = courseCode;
            Title = AppResources.ApplicationTitle.ToUpper() + " " + Code.ToUpper();
            _pinnedCourses = pinnedCourses;

            _toggleSecondaryTileCommand = new DelegateCommand(ToggleSecondaryTile, () => _course != null);

            _openNoppaPage = new DelegateCommand(async delegate { await Launcher.LaunchUriAsync(NoppaPageUri); }, () => NoppaPageUri != null);
            _openOodiPage = new DelegateCommand(async delegate { await Launcher.LaunchUriAsync(OodiPageUri); }, () => OodiPageUri != null);

            NoppaPageUri = new Uri(String.Format("https://noppa.aalto.fi/noppa/kurssi/{0}/etusivu", courseCode));

            // By default, always add these two items (which can be assigned to CurrentContent by the view)
            OverviewModel = new OverviewViewModel();
            NewsModel = new NewsViewModel();

            Contents.Add(OverviewModel);
            Contents.Add(NewsModel);

            SetPinnedStateAsync();
        }
Beispiel #2
0
        private Collection<string> GetCourseCodes()
        {
            Task<ObservableCollection<string>> t = new PinnedCourses().GetCodesAsync();
            t.Wait();

            ObservableCollection<string> codes = t.Result;

            foreach (ShellTile tile in ShellTile.ActiveTiles)
            {
                string code = NoppaTiles.GetCourseCode(tile.NavigationUri);
                if (code != null && codes.Contains(code) == false)
                {
                    codes.Add(code);
                }
            }

            return t.Result;
        }
Beispiel #3
0
        public async Task LoadMyCoursesAsync(PinnedCourses pinnedCourses)
        {
            IsLoading = true;

            Courses.Clear();
            var courses = await pinnedCourses.GetCodesAsync();

            var tasks = new List<Task<Course>>();

            foreach (string c in courses) {
                tasks.Add(Task.Run(async () => await NoppaAPI.GetCourse(c) ));
            }

            while (tasks.Count > 0)
            {
                var course = await Task.WhenAny(tasks);
                tasks.Remove(course);

                Courses.Add(await course);
            }
            IsLoading = false;
        }