public void RemoveEmployee() { AvailableEmployees.Add(SelectedEmployeeToRemove); SelectedEmployees.Remove(SelectedEmployeeToRemove); NotifyOfPropertyChange(() => SelectedEmployees); NotifyOfPropertyChange(() => CanPrint); NotifyOfPropertyChange(() => CanReset); }
private void ApplyFilter() { AvailableEmployees.Clear(); foreach (var employee in _allEmployees.Where(e => _selectedDepartments.Contains(e.Department) && (string.IsNullOrEmpty(SearchText) || e.Name.ToLower().Contains(SearchText.ToLower())))) { AvailableEmployees.Add(employee); } }
private void LoadCompany(int companyId) { var company = companyId != 0 ? _companyRepository.GetById(companyId) : new Company(); Company = new CompanyWrapper(company); if (companyId == 0) { _companyRepository.Add(company); } Employees.Clear(); AvailableEmployees.Clear(); var employees = _employeeRepository.GetAll(); foreach (var employee in employees) { if (employee.CompanyId == null) { AvailableEmployees.Add(new LookupItem { Id = employee.Id, DisplayMember = employee.LastName + " " + employee.FirstName }); continue; } if (employee.CompanyId != companyId) { continue; } Employees.Add(new LookupItem { Id = employee.Id, DisplayMember = employee.LastName + " " + employee.FirstName }); } Company.PropertyChanged += (s, e) => { if (!IsDirty) { IsDirty = _employeeRepository.HasChanges(); SaveCommand.RaiseCanExecuteChanged(); } if (e.PropertyName == nameof(Company.Name)) { IsDirty = _companyRepository.HasChanges(); SaveCommand.RaiseCanExecuteChanged(); } }; }
public void GetEmployees() { //AvailableEmployees = new BindableCollection<EmployeeModel>(GlobalConfig.Connection.GetFullEmployeeInfo()); AvailableEmployees.Add(new EmployeeModel { Id = 1, FirstName = "George", LastName = "Washington", HireDate = Convert.ToDateTime("02/27/2017"), Status = false }); AvailableEmployees.Add(new EmployeeModel { Id = 1, FirstName = "Abraham", LastName = "Lincoln", HireDate = Convert.ToDateTime("03/29/1997"), Status = false }); NotifyOfPropertyChange(() => AvailableEmployees); }
public void RemoveEmployee() { foreach (var item in SelectedEmployees.Where(x => x.IsSelected).Reverse()) { SelectedEmployeeToRemove.IsSelected = false; AvailableEmployees.Add(SelectedEmployeeToRemove); SelectedEmployees.Remove(SelectedEmployeeToRemove); } NotifyOfPropertyChange(() => SelectedEmployees); NotifyOfPropertyChange(() => AvailableEmployees); NotifyOfPropertyChange(() => CanSave); NotifyOfPropertyChange(() => CanReset); SortEmployees(SelectedEmployees); SortEmployees(AvailableEmployees); }
private void OnDeleteExecute() { //var answer = await _dialogService.ShowOkCancelDialog("Warning", // $"Do you really want to remove the employee {SelectedEmployee.DisplayMember} ?"); var answer = _dialogService.ShowOkCancelDialogUsingMsgBox("Warning", $"Do you really want to remove the employee {SelectedEmployee.DisplayMember} ?"); if (answer) { if (EmployeesOnAddedState.Contains(SelectedEmployee)) { var employee = SelectedEmployee; if (Employees.Contains(SelectedEmployee)) { AvailableEmployees.Add(employee); Employees.Remove(employee); } EmployeesOnAddedState.Remove(SelectedEmployee); if (EmployeesOnAddedState.Count == 0) { IsDirty = _employeeRepository.HasChanges(); SaveCommand.RaiseCanExecuteChanged(); } return; } var empoyee = _employeeRepository.GetById(SelectedEmployee.Id); empoyee.CompanyId = null; _employeeRepository.Save(); _eventAggregator.GetEvent <EmployeeStateChanged>().Publish(empoyee.Id); AvailableEmployees.Add(SelectedEmployee); if (Employees.Contains(SelectedEmployee)) { Employees.Remove(SelectedEmployee); } } }
public void RemoveSelectedEmployee() { AvailableEmployees.Add(SelectedAssignedEmployee); AssignedEmployees.Remove(SelectedAssignedEmployee); SelectedAssignedEmployee = null; }