public ActionResult Create(int?id) { try { var game = new GameViewModel(); ViewBag.Teams = new SelectList(teamService.GetTeams(), "Id", "Name"); ViewBag.Stadiums = new SelectList(stadiumService.GetStadiums(), "Id", "Name"); return(View(game)); } catch (ValidationException ex) { return(Content(ex.Message)); } }
// GET: Stadium public ActionResult Index(string sortBy) { IEnumerable <StadiumDTO> stadiumDTOs = stadiumService.GetStadiums(); var mapper = new MapperConfiguration(cfg => cfg.CreateMap <StadiumDTO, StadiumViewModel>()).CreateMapper(); var stadiums = mapper.Map <IEnumerable <StadiumDTO>, List <StadiumViewModel> >(stadiumDTOs).AsQueryable(); ViewBag.NameSort = sortBy == "Name" ? "Name desc" : "Name"; switch (sortBy) { case "Name desc": stadiums = stadiums.OrderByDescending(s => s.Name); break; case "Name": stadiums = stadiums.OrderBy(s => s.Name); break; default: break; } return(View(stadiums)); }
public async Task <List <Stadium> > GetStadiums() { return(await _service.GetStadiums()); }
public async Task <ActionResult <IEnumerable <Domain.Entities.Stadium> > > Get() { return(Ok(await _service.GetStadiums())); }