Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. private void CreateNewDepartment()
  2. {
  3.     /*Serg's Way - It works */
  4.     /*if ((textBox1.Text != String.Empty) && (comboBox1.SelectedIndex >= 0))
  5.     {
  6.         DepartmentRepository departmentRepo = new DepartmentRepository();
  7.         Person user = new Person()
  8.         {
  9.             Name = ((Person)comboBox1.SelectedItem).Name
  10.         };
  11.  
  12.         Department department = new Department()
  13.         {
  14.             Name = textBox1.Text,
  15.             Person = user,
  16.         };
  17.         departmentRepo.Add(department);
  18.         departmentRepo.Save();
  19.     }     */
  20.  
  21.     /*Works also! */
  22.     if ((textBox1.Text != String.Empty) && (comboBox1.SelectedIndex >= 0))
  23.     {
  24.         Person person = (Person)comboBox1.SelectedItem;
  25.         Department department = new Department();
  26.         department.Name = textBox1.Text;
  27.         person.Departments.Add(department);
  28.  
  29.         peopleRepo.Save();
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement