public void GetCentreRankForCentre_returns_expected_value() { // When var result = centresService.GetCentreRankForCentre(3); // Then result.Should().Be(3); }
private void GivenServicesReturnProvidedValues( AdminUser?adminUser, int delegateCount, int courseCount, int adminCount, int centreRank, int ticketCountForAdmin, int ticketCountForCentre ) { A.CallTo(() => centresDataService.GetCentreDetailsById(CentreId)) .Returns(CentreTestHelper.GetDefaultCentre(CentreId)); A.CallTo(() => userDataService.GetAdminUserById(AdminId)) .Returns(adminUser); A.CallTo(() => userDataService.GetNumberOfApprovedDelegatesAtCentre(CentreId)).Returns(delegateCount); A.CallTo( () => courseDataService.GetNumberOfActiveCoursesAtCentreFilteredByCategory( CentreId, adminUser !.CategoryIdFilter ) ).Returns(courseCount); A.CallTo(() => userDataService.GetNumberOfActiveAdminsAtCentre(CentreId)).Returns(adminCount); A.CallTo(() => centresService.GetCentreRankForCentre(CentreId)).Returns(centreRank); A.CallTo(() => supportTicketDataService.GetNumberOfUnarchivedTicketsForAdminId(AdminId)) .Returns(ticketCountForAdmin); A.CallTo(() => supportTicketDataService.GetNumberOfUnarchivedTicketsForCentreId(CentreId)) .Returns(ticketCountForCentre); }
public IActionResult Index() { var adminId = User.GetAdminId() !.Value; var unacknowledgedNotifications = systemNotificationsDataService.GetUnacknowledgedSystemNotifications(adminId).ToList(); if (!Request.Cookies.HasSkippedNotificationsCookie(adminId) && unacknowledgedNotifications.Any()) { return(RedirectToAction("Index", "SystemNotifications")); } var adminUser = userDataService.GetAdminUserById(adminId) !; var centreId = User.GetCentreId(); var centre = centresDataService.GetCentreDetailsById(centreId) !; var delegateCount = userDataService.GetNumberOfApprovedDelegatesAtCentre(centreId); var courseCount = courseDataService.GetNumberOfActiveCoursesAtCentreFilteredByCategory( centreId, adminUser.CategoryIdFilter ); var adminCount = userDataService.GetNumberOfActiveAdminsAtCentre(centreId); var supportTicketCount = ticketDataService.GetNumberOfUnarchivedTicketsForCentreId(centreId); var centreRank = centresService.GetCentreRankForCentre(centreId); var model = new CentreDashboardViewModel( centre, adminUser.FirstName, adminUser.CategoryName, Request.GetUserIpAddressFromRequest(), delegateCount, courseCount, adminCount, supportTicketCount, centreRank, unacknowledgedNotifications.Count ); return(View(model)); }
public CentreDashboardInformation?GetDashboardInformationForCentre(int centreId, int adminId) { var adminUser = userDataService.GetAdminUserById(adminId); var centre = centresDataService.GetCentreDetailsById(centreId); if (centre == null || adminUser == null) { return(null); } var delegateCount = userDataService.GetNumberOfApprovedDelegatesAtCentre(centreId); var courseCount = courseDataService.GetNumberOfActiveCoursesAtCentreFilteredByCategory( centreId, adminUser !.CategoryIdFilter ); var adminCount = userDataService.GetNumberOfActiveAdminsAtCentre(centreId); var supportTicketCount = adminUser.IsCentreManager ? ticketDataService.GetNumberOfUnarchivedTicketsForCentreId(centreId) : ticketDataService.GetNumberOfUnarchivedTicketsForAdminId(adminId); var centreRank = centresService.GetCentreRankForCentre(centreId); return(new CentreDashboardInformation(centre, adminUser, delegateCount, courseCount, adminCount, supportTicketCount, centreRank)); }
public void Setup() { A.CallTo(() => userDataService.GetAdminUserById(A <int> ._)).Returns(UserTestHelper.GetDefaultAdminUser()); A.CallTo(() => centresDataService.GetCentreDetailsById(A <int> ._)) .Returns(CentreTestHelper.GetDefaultCentre()); A.CallTo(() => userDataService.GetNumberOfApprovedDelegatesAtCentre(A <int> ._)).Returns(1); A.CallTo(() => courseDataService.GetNumberOfActiveCoursesAtCentreFilteredByCategory(A <int> ._, A <int> ._)) .Returns(1); A.CallTo(() => userDataService.GetNumberOfActiveAdminsAtCentre(A <int> ._)).Returns(1); A.CallTo(() => ticketDataService.GetNumberOfUnarchivedTicketsForCentreId(A <int> ._)).Returns(1); A.CallTo(() => centresService.GetCentreRankForCentre(A <int> ._)).Returns(1); dashboardController = new DashboardController( userDataService, centresDataService, courseDataService, ticketDataService, centresService, systemNotificationsDataService ).WithMockHttpContext(httpRequest, response: httpResponse) .WithMockUser(true) .WithMockServices() .WithMockTempData(); }