Exemplo n.º 1
0
		public static bool InsertDataIntoDatabase (CourseSection courseSection)
		{
			try {
				SQLiteManagement.CheckAndCreateDatabase ();

				var newCourseSchedule = new CourseSchedule {
					ClassId = courseSection.ClassId,

					FacultyId = courseSection.FacultyId,

					CourseTitle = courseSection.CourseTitleLong,

					ClassSection = courseSection.ClassSection,

					CampusLocation = courseSection.CampusLocation,

					Room = courseSection.Room,

					ClassDays = courseSection.ClassDays,

					ClassStartTime = courseSection.ClassStartTime,

					ClassEndTime = courseSection.ClassEndTime,

					FacultyName = courseSection.FacultyName,

					QuarterLongName = courseSection.QuarterLongName

				};

				var course = CDMService.GetCourse (courseSection.CrseId);
				newCourseSchedule.Subject = course.SubjectId;
				newCourseSchedule.CourseNum = course.CatalogNbr;

				string path = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "CourseSchedule.sqlite");

				using (SQLiteConnection db = new SQLiteConnection (path)) {				
					// create the tables
					db.Insert (newCourseSchedule);

					// close the connection
					db.Close ();
				}

				return true;
			} catch (Exception) {
				return false;
			}

		}
Exemplo n.º 2
0
		public static bool DeleteDataInDatabase (CourseSchedule entity)
		{
			try {
				string path = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "CourseSchedule.sqlite");

				using (SQLiteConnection db = new SQLiteConnection (path)) {				
					// create the tables
					db.Delete<CourseSchedule> (entity.id);

					// close the connection
					db.Close ();
					return true;
				}
			} catch (Exception) {
				return false;
			}
		}