Example #1
0
 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));
     }
 }
Example #2
0
        // 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));
        }
Example #3
0
 public async Task <List <Stadium> > GetStadiums()
 {
     return(await _service.GetStadiums());
 }
Example #4
0
 public async Task <ActionResult <IEnumerable <Domain.Entities.Stadium> > > Get()
 {
     return(Ok(await _service.GetStadiums()));
 }