Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void CreateNewDepartment()
- {
- /*Serg's Way - It works */
- /*if ((textBox1.Text != String.Empty) && (comboBox1.SelectedIndex >= 0))
- {
- DepartmentRepository departmentRepo = new DepartmentRepository();
- Person user = new Person()
- {
- Name = ((Person)comboBox1.SelectedItem).Name
- };
- Department department = new Department()
- {
- Name = textBox1.Text,
- Person = user,
- };
- departmentRepo.Add(department);
- departmentRepo.Save();
- } */
- /*Works also! */
- if ((textBox1.Text != String.Empty) && (comboBox1.SelectedIndex >= 0))
- {
- Person person = (Person)comboBox1.SelectedItem;
- Department department = new Department();
- department.Name = textBox1.Text;
- person.Departments.Add(department);
- peopleRepo.Save();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement