async Task LoadTerm()
        {
            IsBusy = true;
            try
            {
                Term = await SqliteConn.Table <Term>().FirstOrDefaultAsync(t => t.Id == Term.Id);

                Title = $"{Term.Title}'s courses";
                var courses = await SqliteConn.Table <Course>().Where(c => c.TermId == Term.Id).OrderBy(term => term.Start).ToListAsync();

                // Loading the data causes the refresh to trigger
                lock (coursesLock)
                {
                    CanAddCourse = courses.Count < 6;
                    Courses.Clear();
                    foreach (var course in courses)
                    {
                        Courses.Add(course);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.Write(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
        public async Task <bool> SaveCourse()
        {
            NewCourse.Start = StartDate;
            NewCourse.End   = EndDate;
            if (await ValidateCourse(NewCourse))
            {
                if (isUpdate)
                {
                    await SqliteConn.UpdateAsync(NewCourse);
                }
                else
                {
                    var courseCount = await SqliteConn.Table <Course>().Where(c => c.TermId == Term.Id).CountAsync();

                    if (courseCount > 5)
                    {
                        ErrorText = $"* Term '{Term.Title}' has already reached the maximum number of courses of 6.";
                        return(false);
                    }
                    await SqliteConn.InsertAsync(NewCourse);
                }
                return(true);
            }
            return(false);
        }
示例#3
0
        async Task LoadTerms()
        {
            IsBusy = true;
            try
            {
                var terms = await SqliteConn.Table <Term>().OrderBy(term => term.Start).ToListAsync();

                lock (termsLock)
                {
                    Terms.Clear();
                    foreach (var term in terms)
                    {
                        Terms.Add(term);
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.Write(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
示例#4
0
        private async Task LoadCourse()
        {
            IsBusy = true;
            HasObjectiveAssessment   = false;
            HasPerformanceAssessment = false;
            try
            {
                Course = await SqliteConn.Table <Course>().FirstOrDefaultAsync(c => c.Id == Course.Id);

                var assessments = await SqliteConn.Table <Assessment>().Where(a => a.CourseId == Course.Id).ToListAsync();

                lock (assessmentsLock)
                {
                    foreach (var assessment in assessments)
                    {
                        if (assessment.Type == AssessmentType.Objective)
                        {
                            ObjectiveAssessment    = assessment;
                            HasObjectiveAssessment = true;
                        }
                        else
                        {
                            PerformanceAssessment    = assessment;
                            HasPerformanceAssessment = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.Write(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }