예제 #1
0
 public static void UpdateData <T>(T obj)
     where T : class, IObjectDB
 {
     using (MyDBContext context = new MyDBContext())
     {
         T objDb = context.Set <T>().Where(c => c.Id == obj.Id).First <T>();
         HandlingObjects.CopyValueProperties <T>(objDb, obj);
         context.SaveChanges();
     }
 }
예제 #2
0
 public VMEmployeeWindow(Employee employee, Action action, EmployeeWindow employeeWindow, bool isnNew = false)
 {
     IsNew       = isnNew;
     Positions   = DataQueries.SelectPositions();
     Departments = DataQueries.SelectDepartments();
     Salaries    = DataQueries.SelectSalaries();
     UpdateInfo  = action;
     oldEmployee = employee;
     NewEmployee = new Employee();
     if (!IsNew)
     {
         HandlingObjects.CopyValueProperties(NewEmployee, employee);
         SelectedPosition   = Positions.Where(c => c.Id == employee.Position.Id).First();
         SelectedDepartment = Departments.Where(c => c.Id == employee.Department.Id).First();
         SelectedSalary     = Salaries.Where(c => c.Id == employee.Salary.Id).First();
     }
     EmployeeWindow = employeeWindow;
 }
예제 #3
0
        private void SaveEmployeeMethod(Object obj)
        {
            if (obj is Employee)
            {
                HandlingObjects.CopyValueProperties <Employee>(oldEmployee, NewEmployee);

                UpdateInfo?.Invoke();
                if (IsNew)
                {
                    Person person = new Person();
                    HandlingObjects.CopyValueProperties <Person>(person, (Person)oldEmployee);
                    DataQueries.AddData <Person>(person);
                    oldEmployee.FillPerson(person);
                    oldEmployee.Position_id   = oldEmployee.Position.Id;
                    oldEmployee.Department_id = oldEmployee.Department.Id;
                    oldEmployee.Salary_id     = oldEmployee.Salary.Id;
                    DataQueries.AddData <Employee>(oldEmployee);
                }
            }
        }