Beispiel #1
0
        public async Task <IActionResult> DeleteGroup(ChallengeGroupListViewModel model)
        {
            try
            {
                await _challengeService.RemoveGroupAsync(model.ChallengeGroup.Id);

                ShowAlertSuccess($"Category \"{model.ChallengeGroup.Name}\" removed!");
            }
            catch (GraException gex)
            {
                ShowAlertDanger("Unable to remove Challenge Group: ", gex);
            }

            return(RedirectToAction("Groups", new
            {
                search = model.Search,
                page = model.PaginateModel.CurrentPage
            }));
        }
Beispiel #2
0
        public async Task <IActionResult> Groups(string search, int page = 1)
        {
            PageTitle = "Challenge Groups";
            var filter = new ChallengeGroupFilter(page)
            {
                Search = search
            };

            var groupList = await _challengeService.GetPaginatedGroupListAsync(filter);

            var paginateModel = new PaginateViewModel
            {
                ItemCount    = groupList.Count,
                CurrentPage  = page,
                ItemsPerPage = filter.Take.Value
            };

            if (paginateModel.PastMaxPage)
            {
                return(RedirectToRoute(
                           new
                {
                    page = paginateModel.LastPage ?? 1
                }));
            }

            var viewModel = new ChallengeGroupListViewModel()
            {
                ChallengeGroups = groupList.Data,
                PaginateModel   = paginateModel,
                Search          = search,
                CanAddGroups    = UserHasPermission(Permission.AddChallengeGroups),
                CanEditGroups   = UserHasPermission(Permission.EditChallengeGroups)
            };

            return(View(viewModel));
        }