// GET: Matches
 public ActionResult Index()
 {
     //var matches = _uow.Matches.Include(m => m.FirstTeam).Include(m => m.SecondTeam);
     var vm = new MatchIndexViewModel()
     {
         Matches = _uow.Matches.AllIncluding()
     };
     
     return View(vm);
 }
示例#2
0
        // GET: Matches
        public ActionResult Index()
        {
            //var matches = _uow.Matches.Include(m => m.FirstTeam).Include(m => m.SecondTeam);
            var vm = new MatchIndexViewModel()
            {
                Matches = _uow.Matches.AllIncluding()
            };

            return(View(vm));
        }
示例#3
0
        public async Task <IActionResult> Filter(string sortOrder, string searchTerm, int?pageSize, int?pageNumber)
        {
            sortOrder  = sortOrder ?? string.Empty;
            searchTerm = searchTerm ?? string.Empty;

            var matches = await _matchService.FilterMatchesAsync(sortOrder, searchTerm, pageNumber ?? 1, pageSize ?? 10);

            var model = new MatchIndexViewModel(matches, sortOrder, searchTerm);

            return(PartialView("_MatchTablePartial", model.Table));
        }
示例#4
0
        public async Task <IActionResult> Index()
        {
            if (!_memoryCache.TryGetValue("ListOfMatches", out IPagedList <Match> matches))
            {
                matches = await _matchService.FilterMatchesAsync();

                MemoryCacheEntryOptions options = new MemoryCacheEntryOptions
                {
                    AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(25),
                    SlidingExpiration = TimeSpan.FromSeconds(5)
                };

                _memoryCache.Set("ListOfMatches", matches, options);
            }

            var model = new MatchIndexViewModel(matches);

            return(View(model));
        }
        // GET: Matches
        public async Task <IActionResult> Index(int?teamId)
        {
            var data = await _context.Matches
                       .Include(m => m.Season)
                       .ThenInclude(s => s.League)
                       .Include(m => m.MatchDetail)
                       .ThenInclude(md => md.Team)
                       .OrderBy(match => match.MatchDate)
                       .ToListAsync();

            if (teamId != null && teamId > 0)
            {
                data = data.Where(match => match.MatchDetail.Where(md => md.TeamId == teamId).Any()).ToList();
            }

            var view = new MatchIndexViewModel()
            {
                Matches = data.GroupBy(match => match.Season),
                Teams   = await _context.Teams.ToListAsync()
            };

            return(View(view));
        }