private IEnumerable<DraftCardViewModel> GetUpdatedDraftCards(TeamViewModel teamVm) { if (CurrentPick == null) { return null; } return DraftRounds.Where(round => round.RoundNumber < CurrentPick.RoundNumber).Select(round => round.DraftPicks.Where(pick => pick.Player != null).SingleOrDefault(x => x.PickNumber == teamVm.DraftOrder)); }
public static TeamViewModel ToViewModel(this FMDraft.Library.Entities.Team team, GameCore core) { var vm = new TeamViewModel(core) { BackgroundColor = team.BackgroundColor, ForegroundColor = team.ForegroundColor, City = team.City, Name = team.Name, DraftOrder = team.DraftOrder, Manager = new ManagerViewModel(core) }; if (team.Stadium != null) { vm.StadiumAttendances = team.Stadium.Attendances; vm.StadiumName = team.Stadium.Name; } if (team.ManagerMode == ManagerMode.CPU && team.Manager != null) { vm.Manager.Name = team.Manager.FullName; vm.Manager.ID = team.Manager.ID; } if (team.ManagerMode == ManagerMode.Player) { vm.HumanControlled = true; } if (team.DraftCards != null) { vm.DraftCards = new ObservableCollection<DraftCardViewModel>(team.DraftCards.Select(x => x.ToViewModel(core))); vm.DraftCards.CollectionChanged += (sender, e) => { vm.NotifyPropertyChanged("SeniorPlayers"); vm.NotifyPropertyChanged("YouthPlayers"); }; } return vm; }