Example #1
0
        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 centreId = User.GetCentreId();

            var dashboardInformation = dashboardInformationService.GetDashboardInformationForCentre(centreId, adminId);

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

            var model = new CentreDashboardViewModel(
                dashboardInformation,
                Request.GetUserIpAddressFromRequest(),
                unacknowledgedNotifications.Count
                );

            return(View(model));
        }
Example #2
0
        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));
        }