public DepartmentViewModel(DepartmentModel department) { OkCommand = new RelayCommand(DoOk); CancelCommand = new RelayCommand(DoCancel); SelectedSupervisor = -1; Supervisors = new WorkersManager().GetWorkers(); if (department == null) { Department = new DepartmentModel(); } else { Department = department.Clone(); SelectedSupervisor = Supervisors.IndexOf(Supervisors.Where(s => s.Id == department.Supervisor).FirstOrDefault()); } }