public TeamEdit Build(int id) { var team = _teamService.Get(id); var sports = MvcService.BuildSportsSelectList(_sportService.Get(), team.Sport != null ? team.Sport.Id : 0); var leagues = MvcService.BuildLeaguesSelectList(_leagueService.Get(), team.League != null ? team.League.Id : 0); var colleges = MvcService.BuildCollegesSelectList(_collegeService.Get(), team.College != null ? team.College.Id : 0); var vm = new TeamEdit { DisplayName = team.ToString(), Sports = sports, Leagues = leagues, Colleges = colleges, TeamVM = new TeamViewModel { Id = team.Id, Identifier = team.Identifier, City = team.City, Nickname = team.Nickname, NotableFlag = team.NotableFlag, CollegeId = team.College == null ? 0 : team.College.Id, SportId = team.Sport == null ? 0 : team.Sport.Id, LeagueId = team.League == null ? 0 : team.League.Id } }; return(vm); }
public TeamIndex Build(TeamFilterOptionsViewModel filterOptionsVM) { var teamSearchFilterOptions = SearchFilterService.BuildTeamSearchFilterOptions(filterOptionsVM); if (teamSearchFilterOptions == null) { teamSearchFilterOptions = new TeamSearchFilterOptions(); } var teamSearch = _teamSearchService.Get(teamSearchFilterOptions); var sports = _sportService.Get(); var leagues = _leagueService.Get(); var teamList = teamSearch.Teams.Select(x => new TeamListItemViewModel { Id = x.Id, Name = x.ToString(), LeagueName = x.League != null? x.League.Name : "", SportName = x.Sport != null ? x.Sport.Name : "", CollegeId = x.College != null ? x.College.Id : 0, CollegeName = x.College != null ? x.College.Name : "" }) .ToList(); var teamSearchViewModel = new TeamIndex { TeamFilterOptionsViewModel = filterOptionsVM, Teams = teamList, Sports = MvcService.BuildSportsSelectList(sports, teamSearchFilterOptions.SportId ?? 0), Leagues = MvcService.BuildLeaguesSelectList(leagues, teamSearchFilterOptions.LeagueId ?? 0) }; return(teamSearchViewModel); }
public PersonEdit Build(int id) { var person = _personService.Get(id); var sportIds = person.Sports.Select(x => x.Id).ToList(); int collegeId = 0; if (person.College != null) { collegeId = person.College.Id; } var colleges = _collegeService.Get(); var sports = _sportService.Get(); var collegesSelectList = MvcService.BuildCollegesSelectList(colleges, collegeId); var sportSelectList = MvcService.BuildSportsSelectList(sports, 0, ""); var vm = new PersonEdit { DisplayName = person.ToString(), Colleges = collegesSelectList, Sports = sportSelectList, PersonVM = new PersonViewModel { Id = person.Id, Identifier = person.Identifier, LastName = person.LastName, FirstName = person.FirstName, MiddleName = person.MiddleName, Suffix = person.Suffix, HOFFlag = person.HOFFlag, HeismanFlag = person.HeismanFlag, NotableFlag = person.NotableFlag, CollegeId = collegeId, SportIds = sportIds } }; return(vm); }
public PersonIndex Build(PersonFilterOptionsViewModel filterOptionsViewModel) { var personSearchFilterOptions = SearchFilterService.BuildPersonSearchFilterOptions(filterOptionsViewModel); if (personSearchFilterOptions == null) { personSearchFilterOptions = new PersonSearchFilterOptions(); } var personSearch = _personSearchService.Get(personSearchFilterOptions); var teams = _teamService.Get(); var sports = _sportService.Get(); var leagues = _leagueService.Get(); var peopleList = personSearch.People.Select(x => new PersonListItemViewModel { Id = x.Id, Name = x.LastName == null ? string.Format("[{0}]", x.Identifier) : x.ToString(), CollegeId = x.College != null ? x.College.Id : 0, CollegeName = x.College != null ? x.College.Name : "", SportNames = x.Sports != null ? BuildSportNames(x.Sports) : "", HOFFlag = x.HOFFlag == true ? "HOF" : "", HeismanFlag = x.HeismanFlag == true ? "Heisman" : "", NotableFlag = x.NotableFlag == true ? "Notable" : "", }) .ToList(); var personSearchViewModel = new PersonIndex { PersonFilterOptionsViewModel = filterOptionsViewModel, People = peopleList, Sports = MvcService.BuildSportsSelectList(sports, personSearchFilterOptions.SportId ?? 0), Leagues = MvcService.BuildLeaguesSelectList(leagues, personSearchFilterOptions.LeagueId ?? 0), Teams = MvcService.BuildTeamsSelectList(teams, personSearchFilterOptions.TeamId ?? 0) }; return(personSearchViewModel); }