public IActionResult ConfirmDeleteGroup(int groupId, ConfirmDeleteGroupViewModel model) { if (!ModelState.IsValid) { return(View(model)); } groupsService.DeleteDelegateGroup(groupId, model.DeleteEnrolments); return(RedirectToAction("Index")); }
public IActionResult ConfirmDeleteGroup(int groupId) { var groupLabel = groupsService.GetGroupName(groupId, User.GetCentreId()) !; var delegateCount = groupsService.GetGroupDelegates(groupId).Count(); var courseCount = groupsService.GetUsableGroupCoursesForCentre(groupId, User.GetCentreId()).Count(); var model = new ConfirmDeleteGroupViewModel { GroupLabel = groupLabel, DelegateCount = delegateCount, CourseCount = courseCount, }; return(View(model)); }
public void ConfirmDeleteGroup_with_deleteEnrolments_true_deletes_group_correctly() { // Given A.CallTo(() => groupsService.GetGroupCentreId(A <int> ._)) .Returns(delegateGroupsController.User.GetCentreId()); var model = new ConfirmDeleteGroupViewModel { DeleteEnrolments = true, Confirm = true, }; const int groupId = 1; // When var result = delegateGroupsController.ConfirmDeleteGroup(groupId, model); // Then A.CallTo(() => groupsService.DeleteDelegateGroup(groupId, true)).MustHaveHappenedOnceExactly(); result.Should().BeRedirectToActionResult().WithActionName("Index"); }