Exemple #1
0
        public NewTeamViewModel(TeamsViewModel teamsViewModel, Team currentTeam)
        {
            TeamsViewModel = teamsViewModel;
            CurrentTeam    = currentTeam;

            // If the currentTeam parameter is set, we are editing a team
            if (currentTeam != null)
            {
                IncludedWorkers = new ObservableCollection <Worker>(CurrentTeam.Workers);
                ExcludedWorkers = new ObservableCollection <Worker>();
                foreach (Worker worker in DbOperations.GetAllWorkers())
                {
                    if (!IncludedWorkers.Contains(worker))
                    {
                        ExcludedWorkers.Add(worker);
                    }
                }
            }
            // If it is null, we are creating a new team,
            // all of the workers will be in the excluded list, since the team is not created yet
            else
            {
                CurrentTeam     = new Team();
                ExcludedWorkers = new ObservableCollection <Worker>(DbOperations.GetAllWorkers());
                IncludedWorkers = new ObservableCollection <Worker>();
            }
        }
Exemple #2
0
 public void Save()
 {
     CurrentTeam.Workers = IncludedWorkers.ToList();
     TeamsViewModel.AddOrEditTeam(CurrentTeam);
 }