Example #1
0
        public async Task TestGenerateOneDayTimeTableModel()
        {
            await LoginAssist();

            var table = await assist.GetTableCourses(assist.GetTableSemesters().Result[0]);

            var model = await TimeTableHelper.GenerateOneDayTimeTableModel(table);

            Assert.IsTrue(model.Courses.Count >= 0);
            if (model.Courses.Count > 0)
            {
                Assert.IsTrue(model.Courses[0].Name.Length > 0);
            }
        }
Example #2
0
        private async void LoadTimeTables()
        {
            try
            {
                TimeTableProgressBar.Visibility = Visibility.Visible;

                if (app.TimeTables == null)
                {
                    Debug.WriteLine("Started: Load Timetable");
                    Windows.Storage.StorageFolder storageFolder =
                        Windows.Storage.ApplicationData.Current.LocalFolder;
                    Windows.Storage.StorageFile file =
                        await storageFolder.GetFileAsync("timetable.txt");

                    string text = await Windows.Storage.FileIO.ReadTextAsync(file);

                    app.TimeTables = JsonConvert.DeserializeObject <List <TableCourses> >(text);
                    Debug.WriteLine("Finished: Load Timetable");
                }

                if (app.HomePage_Models == null)
                {
                    foreach (var table in app.TimeTables)
                    {
                        TimetableModels.Add(await TimeTableHelper.GenerateOneDayTimeTableModel(table));
                    }
                    app.HomePage_Models = TimetableModels.ToList();
                }
                else
                {
                    foreach (var item in app.HomePage_Models)
                    {
                        TimetableModels.Add(item);
                    }
                }
            }
            catch (FileNotFoundException)
            {
                app.TimeTables = new List <TableCourses>();
                SaveTimeTables();
            }
            finally
            {
                TimeTableProgressBar.Visibility = Visibility.Collapsed;
            }
        }