public void ModifyEntity(Employee employee)
        {
            EmployeeDTO employeeDTO = AllEmployees.Where <EmployeeDTO>(x => x.ID == employee.ID).FirstOrDefault();

            if (employeeDTO == null)
            {
                employeeDTO = new EmployeeDTO()
                {
                    ID      = employee.ID,
                    FIO     = employee.FIO,
                    Company = new CompanyDTO {
                        ID = employee.Company.ID, Name = employee.Company.Name
                    }
                };
                AllEmployees.Add(employeeDTO);
            }
            else
            {
                AllEmployees.Remove(employeeDTO);
                employeeDTO = new EmployeeDTO()
                {
                    ID      = employee.ID,
                    FIO     = employee.FIO,
                    Company = new CompanyDTO {
                        ID = employee.Company.ID, Name = employee.Company.Name
                    }
                };
                AllEmployees.Add(employeeDTO);
            }
        }
Example #2
0
 public void DeleteEmployee(Employee employee)
 {
     employeeService.DeleteEmployee(employee);
     AllEmployees.Remove(employee);
     Filter();
     Search();
     mainWindow.DisplayEmployeesList();
 }
        /// <summary>
        /// We get the picked employee and sends it to be deleted from DB
        /// </summary>
        /// <param name="employee"></param>
        public void DeleteEmployee(Employee employee)
        {
            ApiHelper.Instance.DeleteEmployee(employee.EmployeeId);

            foreach (Employee e in AllEmployees.ToList())
            {
                if (e.EmployeeId == employee.EmployeeId)
                {
                    AllEmployees.Remove(e);
                    AllUsers.Remove(e);
                }
            }
        }
        private void DeleteEmployeeExecute(object parameter)
        {
            // update model
            using (IUnitOfWork unitOfWork = m_unitOfWorkFactory.Create())
            {
                Employee storedEmployee = unitOfWork.Employees.Get(SelectedEmployee.EmployeeId);
                unitOfWork.Employees.Remove(storedEmployee);
                unitOfWork.Complete();
            }

            // update viewmodel
            AllEmployees.Remove(SelectedEmployee);
            SelectedEmployee = null;
        }
Example #5
0
 void RemoveExecute(object param)
 {
     AllEmployees.Remove(SelectEmployee);
 }