示例#1
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"));
        }
示例#2
0
        public void DeleteGroup_deletes_group_with_no_delegates_or_courses()
        {
            // Given
            A.CallTo(() => groupsService.GetGroupCentreId(A <int> ._))
            .Returns(delegateGroupsController.User.GetCentreId());
            const int groupId = 1;

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

            // Then
            A.CallTo(() => groupsService.DeleteDelegateGroup(groupId, false)).MustHaveHappenedOnceExactly();
            result.Should().BeRedirectToActionResult().WithActionName("Index");
        }
示例#3
0
        public void DeleteDelegateGroup_calls_expected_data_services()
        {
            // Given
            const int  groupId = 1;
            const bool deleteStartedEnrolment = true;
            var        dateTime = DateTime.UtcNow;

            A.CallTo(() => clockService.UtcNow).Returns(dateTime);

            // When
            groupsService.DeleteDelegateGroup(groupId, deleteStartedEnrolment);

            // Then
            A.CallTo(
                () => groupsDataService.RemoveRelatedProgressRecordsForGroup(
                    groupId,
                    deleteStartedEnrolment,
                    dateTime
                    )
                ).MustHaveHappenedOnceExactly();
            A.CallTo(() => groupsDataService.DeleteGroupDelegates(groupId)).MustHaveHappenedOnceExactly();
            A.CallTo(() => groupsDataService.DeleteGroupCustomisations(groupId)).MustHaveHappenedOnceExactly();
            A.CallTo(() => groupsDataService.DeleteGroup(groupId)).MustHaveHappenedOnceExactly();
        }