public void UpdateAssignmentPerCourses(ASSIGNMENT_PER_COURSE assignmentPerCourse, DataClasses1DataContext db) { Assignment assignment = new Assignment(); ASSIGNMENT aSSignment = new ASSIGNMENT(); Course course = new Course(); Console.WriteLine("\n\n\t" + "UPATE ASSIGNMENTS PER COURSES" + "\n\t-----------------------------"); aSSignment = assignment.UpdateAssignment(db, aSSignment); int courseID = GetCourseIdFromAssignmentID(db, aSSignment.ASSIGNMENT_ID); assignmentPerCourse.ASSIGNMENT_ID = aSSignment.ASSIGNMENT_ID; assignmentPerCourse.COURSE_ID = courseID; db.SubmitChanges(); Console.WriteLine("\n\tAssignments Per Courses was successfully enrolled!!!"); }
public void CreateTrainerPerCourses(ASSIGNMENT_PER_COURSE assignmentPerCourse, DataClasses1DataContext db) { Course course = new Course(); Assignment assignment = new Assignment(); ASSIGNMENT aSSignmnet = new ASSIGNMENT(); Console.WriteLine("\n\n\t" + "CREATE ASSIGNMENTS PER COURSES" + "\n\t------------------------------"); aSSignmnet = assignment.CreateAssignment(aSSignmnet, db); int courseID = course.GetCourseIDForCreate(); assignmentPerCourse.ASSIGNMENT_ID = aSSignmnet.ASSIGNMENT_ID; assignmentPerCourse.COURSE_ID = courseID; db.ASSIGNMENT_PER_COURSEs.InsertOnSubmit(assignmentPerCourse); db.SubmitChanges(); Console.WriteLine("\n\tΤhe student was successfully enrolled!!!"); }
public void MenuAssignmentPerCourse(DataClasses1DataContext db) { ASSIGNMENT_PER_COURSE assignmentPerCourse = new ASSIGNMENT_PER_COURSE(); string stringChoice; Console.WriteLine("\n\tASSIGNMENT PER COURSE MENU\n\t" + "--------------------------"); Console.WriteLine("\tCreate ASSIGNMENT PER COURSE press ---> {1}"); Console.WriteLine("\tRead ASSIGNMENT PER COURSE press ---> {2}"); Console.WriteLine("\tUpdate ASSIGNMENT PER COURSE press ---> {3}"); Console.WriteLine("\tDelete ASSIGNMENT PER COURSE press ---> {4}"); Console.Write("\tEnter a choice between ---> {1 - 4}: "); stringChoice = Console.ReadLine(); Console.WriteLine(); int outChoice; while (!int.TryParse(stringChoice, out outChoice) || outChoice < 1 || outChoice > 4) { Console.WriteLine("\n\tThe choice should be Only integer between {1- 4}!!!"); Console.Write("\tEnter a new choice: "); stringChoice = Console.ReadLine(); } int choice = outChoice; switch (choice) { case (int)SelectionAssignmentPerCourse.create: CreateTrainerPerCourses(assignmentPerCourse, db); break; case (int)SelectionAssignmentPerCourse.read: ReadAssignmentPerCourses(db); break; case (int)SelectionAssignmentPerCourse.update: UpdateAssignmentPerCourses(assignmentPerCourse, db); break; case (int)SelectionAssignmentPerCourse.delete: DeletAssignmentsPerCourses(assignmentPerCourse, db); break; } }
public void DeletAssignmentsPerCourses(ASSIGNMENT_PER_COURSE assignmentPerCourse, DataClasses1DataContext db) { Course course = new Course(); ASSIGNMENT aSSignment = new ASSIGNMENT(); Assignment assignment = new Assignment(); Console.WriteLine("\n\n\t" + "DELETE ASSIGNMENTS PER COURSES" + "\n\t------------------------------"); int assignmentID = assignment.GetAssignmentIdFOfCreate(); int courseID = GetCourseIdFromAssignmentID(db, aSSignment.ASSIGNMENT_ID); assignmentPerCourse = db.ASSIGNMENT_PER_COURSEs.Single(i => i.ASSIGNMENT_ID == assignmentID); assignmentPerCourse.ASSIGNMENT_ID = assignmentID; assignmentPerCourse.COURSE_ID = courseID; db.ASSIGNMENT_PER_COURSEs.DeleteOnSubmit(assignmentPerCourse); db.SubmitChanges(); Console.WriteLine("\n\tDeleted Succesfully!!!"); }