public TeamDetailsDTO Get(int id) { Team Team = ITeamRepository.Get(id); TeamDetailsDTO TeamDTO = new TeamDetailsDTO() { Team_name = Team.Team_name, RealeaseYear = Team.RealeaseYear, Image = Team.Image }; IEnumerable <Employee> employees = IEmployeeRepository.GetAll().Where(x => x.TeamId == id); if (employees != null) { List <string> employeeNames = employees.Select(x => x.First_name + " " + x.Second_name).ToList(); TeamDTO.Employees = employeeNames; } IEnumerable <TeamRace> teamRaces = ITeamRaceRepository.GetAll().Where(x => x.TeamId == id); if (teamRaces != null) { List <string> races = new List <string>(); foreach (TeamRace teamRace in teamRaces) { Race race = IRaceRepository.GetAll().SingleOrDefault(x => x.Id == teamRace.RaceId); races.Add(race.Location); } TeamDTO.Races = races; } return(TeamDTO); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { _raceRepository = new RaceRepository(); var races = _raceRepository.GetAll(); RaceList.DataSource = races; RaceList.DataValueField = "Id"; RaceList.DataTextField = "Name"; RaceList.DataBind(); var item = RaceList.Items.FindByValue(_raceId); if (item != null) item.Selected = true; } }
public ActionResult <IEnumerable <Race> > Get() { return(IRaceRepository.GetAll()); }