Exemple #1
0
        public ActionResult Index()
        {
            var model = new TeamsIndexViewModel
            {
                Teams = _db.Teams.Include(c => c.Contests).Include(p => p.Participants).ToList()
            };

            return(View(model));
        }
        // GET: Teams
        public async Task <ActionResult> Index()
        {
            var currentUser = await _userManager.FindByIdAsync(User.Identity.GetUserId());

            if (currentUser == null)
            {
                return(RedirectToAction("LogOff", "Account")); //If the user is here without a found user then it must be an old cookie
            }
            var model = new TeamsIndexViewModel(currentUser.Colleagues.Select(colleagues => colleagues.Colleague).ToList(), currentUser.Teams.ToList());

            return(View(model));
        }
        // GET: Teams
        public async Task <IActionResult> Index(TeamsIndexViewModel model)
        {
            model.Pager             = new PagerViewModel();
            model.Pager.CurrentPage = model.Pager.CurrentPage <= 0 ? 1 : model.Pager.CurrentPage;

            List <Team> items = await _context.Teams.Skip((model.Pager.CurrentPage - 1) *PageSize).
                                Take(PageSize).Select(u => new Team()
            {
                Id               = u.Id,
                TeamName         = u.TeamName,
                Developers       = u.Developers,
                WorkingOnProject = u.WorkingOnProject,
                Leader           = u.Leader
            }).Where(x => x.TeamName != "-").ToListAsync();

            model.Items            = items;
            model.Pager.PagesCount = (int)Math.Ceiling(await _context.Teams.CountAsync() / (double)PageSize);

            return(View(model));
        }