public FormFacultyDetails(Faculty target) { Target = target; InitializeComponent(); }
Faculty CreateFaculty(string fname, string lname, string pphone, string pemail, string sphone = null, string semail = null) { Contact contact = new Contact() { PrimaryEmail = pemail, PrimaryNumber = pphone, SecondaryEmail = semail, SecondaryNumber = sphone, }; Program.Database.Contacts.Add(contact); // Find whatever majors they are going to be teaching List<string> selectedMajors = GetSelectedNames(CheckedListBoxNewFacultyMajors); var majors = from search in Program.Database.Majors where selectedMajors.Contains(search.Major1) select search; Faculty result = new Faculty() { ContactID = contact.ContactID, FName = fname, LName = lname, WorkStatus = "F", }; // Create the major relationships foreach (Major major in majors) { FacultyMajor relationship = new FacultyMajor() { FacultyID = result.FacultyID, MajorID = major.MajorID, }; Program.Database.FacultyMajors.Add(relationship); } Program.Database.Faculties.Add(result); Program.Database.SaveChanges(); return result; }