public void Index_returns_view_result_with_correct_group_id_for_centre()
        {
            // Given
            A.CallTo(() => groupsService.GetGroupName(1, 2)).Returns("Group");
            A.CallTo(() => groupsService.GetGroupDelegates(1)).Returns(new List <GroupDelegate>());

            // When
            var result = groupDelegatesController.Index(1);

            // Then
            result.Should().BeViewResult().WithDefaultViewName();
        }
Ejemplo n.º 2
0
        public IActionResult DeleteGroup(int groupId, ReturnPageQuery returnPageQuery)
        {
            var delegates = groupsService.GetGroupDelegates(groupId);
            var courses   = groupsService.GetUsableGroupCoursesForCentre(groupId, User.GetCentreId());

            if (delegates.Any() || courses.Any())
            {
                return(RedirectToAction("ConfirmDeleteGroup", new { groupId, returnPageQuery }));
            }

            groupsService.DeleteDelegateGroup(groupId, false);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        public IActionResult GroupDelegates(int groupId, int page = 1)
        {
            var centreId  = User.GetCentreId();
            var groupName = groupsService.GetGroupName(groupId, centreId);

            if (groupName == null)
            {
                return(NotFound());
            }

            var groupDelegates = groupsService.GetGroupDelegates(groupId);

            var model = new GroupDelegatesViewModel(groupId, groupName, groupDelegates, page);

            return(View(model));
        }
Ejemplo n.º 4
0
        public IActionResult Index(int groupId, int page = 1)
        {
            var centreId  = User.GetCentreId();
            var groupName = groupsService.GetGroupName(groupId, centreId);

            var groupDelegates = groupsService.GetGroupDelegates(groupId);

            var searchSortPaginationOptions = new SearchSortFilterAndPaginateOptions(
                null,
                null,
                null,
                new PaginationOptions(page)
                );
            var result = searchSortFilterPaginateService.SearchFilterSortAndPaginate(
                groupDelegates,
                searchSortPaginationOptions
                );

            var model = new GroupDelegatesViewModel(groupId, groupName !, result);

            return(View(model));
        }
Ejemplo n.º 5
0
        public void GetGroupDelegates_returns_expected_group_delegates()
        {
            // Given
            const int groupId        = 1;
            var       groupDelegates = Builder <GroupDelegate> .CreateListOfSize(10).Build();

            A.CallTo(() => groupsDataService.GetGroupDelegates(groupId)).Returns(groupDelegates);

            // When
            var result = groupsService.GetGroupDelegates(groupId).ToList();

            // Then
            result.Should().HaveCount(10);
            result.Should().BeEquivalentTo(groupDelegates);
        }
Ejemplo n.º 6
0
        public void GroupDelegates_returns_view_result_with_correct_group_id_for_centre()
        {
            // Given
            A.CallTo(() => groupsService.GetGroupName(1, 2)).Returns("Group");
            A.CallTo(() => groupsService.GetGroupDelegates(1)).Returns(new List <GroupDelegate>());

            // When
            var result = delegateGroupsController.GroupDelegates(1);

            // Then
            result.Should().BeViewResult().WithDefaultViewName();
            result.As <ViewResult>().Model.As <GroupDelegatesViewModel>().NavViewModel.GroupName.Should().Be("Group");
            result.As <ViewResult>().Model.As <GroupDelegatesViewModel>().NavViewModel.CurrentPage.Should()
            .Be(DelegateGroupPage.Delegates);
        }
Ejemplo n.º 7
0
        public void DeleteGroup_redirects_to_confirmation_if_group_has_delegates()
        {
            // Given
            A.CallTo(() => groupsService.GetGroupCentreId(A <int> ._))
            .Returns(delegateGroupsController.User.GetCentreId());
            A.CallTo(() => groupsService.GetGroupDelegates(A <int> ._))
            .Returns(new List <GroupDelegate> {
                new GroupDelegate()
            });
            const int groupId = 1;

            // When
            var result = delegateGroupsController.DeleteGroup(
                groupId,
                ReturnPageQueryHelper.GetDefaultReturnPageQuery()
                );

            // Then
            result.Should().BeRedirectToActionResult()
            .WithActionName("ConfirmDeleteGroup")
            .WithRouteValue("groupId", groupId);
        }