protected override void LoadInitalData() { db.Teams.Take(50).Load(); TeamList = db.Teams.Local.OrderBy(t => t.TeamName).ToList(); SelectedTeam = TeamList.FirstOrDefault(); ResetSearch(null); }
private void RemoveTeam(object parameter) { if (SelectedTeam != null && (MessageBox.Show("Are you sure you want to delete " + SelectedTeam.TeamName, "Training Database", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)) { IEnumerable <int> idlist = TeamList.Select(t => t.ID); db.Teams.Remove(SelectedTeam); //SaveDataChanges(null); TeamList = db.Teams.Local.Where(t => idlist.Contains(t.ID)).OrderBy(t => t.TeamName).ToList(); SelectedTeam = TeamList.FirstOrDefault(); NotifyPropertyChanged("Changed"); } }
private void Search(object parameter) { //Cannot get a ID from a null object so need to check if null first int? SearchMHCID = (SearchMHC == null) ? 0 : SearchMHC.ID; string SearchBoroID = (SearchBorough == null) ? null : SearchBorough.ID; int? SearchServID = (SearchService == null) ? 0 : SearchService.ID; int? SearchCohortID = (SearchCohort == null) ? 0 : SearchCohort.ID; int? SearchLeaderID = (SearchLeader == null) ? 0 : SearchLeader.ID; TeamList = db.search_team(SearchName, SearchMHCID, SearchBoroID, SearchServID, SearchLeaderID, SearchCohortID, SearchNoTrain, SearchHasMem).OrderBy(t => t.TeamName).ToList(); SelectedTeam = TeamList.FirstOrDefault(); }