private void SaveTestInfoBtn_Clicked(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(AssessmentIDCell.Text) || string.IsNullOrWhiteSpace(AssessmentNameCell.Text) || string.IsNullOrWhiteSpace(AssessmentInfoCell.Text)) { DisplayAlert("Error", "Please input correct data", "OK"); } else { if (StartDate.Date > CoursePage.course.StartDate && StartDate.Date < CoursePage.course.EndDate) { int id = Convert.ToInt32(AssessmentIDCell.Text); string name = AssessmentNameCell.Text; string info = AssessmentInfoCell.Text; DateTime start = StartDate.Date; DateTime time = start + StartTime.Time; string type = TypePicker.SelectedItem.ToString(); Assessment ass = new Assessment(id, CoursePage.course.CourseID, name, start, time, info, type); CoursePage.course.Assessments.Add(ass); WGU.AddAssessment(new Assessment(id, CoursePage.course.CourseID, name, start, time, info, type)); Navigation.PopAsync(); } else { DisplayAlert("Error", "Test Date is Invalid. Test Date must be after the course starts and before the course ends, thank you.", "Ok"); } } } catch (ArgumentNullException ex) { DisplayAlert("Error", ex.Message, "OK"); } catch (FormatException f) { DisplayAlert("Error", f.Message, "OK"); } }
private void PopulateDB() { if (terms1.Count <= 0) { Term newTerm = new Term(1, "Term 1", new DateTime(2021, 01, 01), new DateTime(2021, 07, 01), new ObservableCollection <Course>()); Course newCourse = new Course(123, newTerm.TermID, "Intro To Programming", new DateTime(2021, 01, 01), new DateTime(2021, 03, 01), "In Progress", "This course is just as it says in the title an introduction class to programming and its many uses in modern society.", "", new CourseInstructor(), new ObservableCollection <Assessment>()); Assessment assessment2 = new Assessment(121, newCourse.CourseID, "Simple Coding Project", new DateTime(2021, 02, 28), new DateTime(2021, 01, 31, 23, 55, 55), "This assessment is a simple coding project to test the students skill in efficient and correct coding techniques.", "Performance Assessment"); Assessment assessment1 = new Assessment(120, newCourse.CourseID, "120 Coding Test", new DateTime(2021, 01, 31), new DateTime(2021, 01, 31, 15, 00, 00), "This Coding Test is designed to determine the current knowledge base of the student prior to their Coding Project Assignment.", "Objective Assessment"); newTerm.Courses.Add(newCourse); newCourse.Instructor = WGU.Instructor; newCourse.Assessments.Add(assessment1); newCourse.Assessments.Add(assessment2); WGU.conn.InsertOrReplace(newTerm); WGU.conn.InsertOrReplace(newCourse); WGU.conn.InsertOrReplace(assessment1); WGU.conn.InsertOrReplace(assessment2); WGU.conn.InsertOrReplace(WGU.Instructor); FillTerms(); FillCourses(); } }