Ejemplo n.º 1
0
        public IActionResult Groups()
        {
            var users = userManager.Users
                        .OrderBy(x => x.ShortName)
                        .ToList();

            var groups        = groupService.GetGroups();
            var mappedUsers   = mapper.Map <List <UserDetailsViewModel> >(users);
            var currentUserId = userManager.GetUserId(User);
            var isAdmin       = User.IsInRole(Constants.ROLE_ADMIN);

            groupService.ArrangeTeamBets(groups, mappedUsers, currentUserId, isAdmin);

            var roundPoints = groupService.GetRoundResults(groups, users.Count);
            var bonusPoints = roundService.GetBonusResults(roundPoints);
            var totalPoints = roundService.GetTotalResults(roundPoints, bonusPoints);

            var model = new GroupsViewModel()
            {
                Users       = mappedUsers,
                Groups      = groups,
                RoundPoints = roundPoints,
                BonusPoints = bonusPoints,
                TotalPoints = totalPoints
            };


            return(View(model));
        }