Beispiel #1
0
        public IActionResult Index(
            [FromServices] IActivityManager activityManager
            )
        {
            var platforms = _platformManager.GetPlatforms();

            foreach (var platform in platforms)
            {
                platform.Tenant = $"{HttpContext.Request.Scheme}://{platform.Tenant}.{HttpContext.Request.Host}";
            }

            ViewBag.Platforms = platforms;

            var activities         = activityManager.GetActivityFeed();
            var activityViewModels = new List <ActivityViewModel>();

            foreach (var activity in activities.Reverse())
            {
                var vm = new ActivityViewModel(activity);
                activityViewModels.Add(vm);
            }

            ViewBag.Activities = activityViewModels;

            return(View());
        }
        //TODO usermanger meegeven in index of in constructor?! Refactor Jeroen please, vraag aan Sam voor refactor
        public IActionResult Index(string tenant, [FromServices] IIdeationManager ideationManager,
                                   [FromServices] UserManager <User> userManager, [FromServices] IIoTManager ioTManager)
        {
            var platform = _platformManager.GetPlatformByTenant(tenant);

            if (platform == null)
            {
                return(RedirectToAction("NotFound", "Home"));
            }

            var activities         = _activityManager.GetActivityFeed(platform);
            var activityViewModels = new List <ActivityViewModel>();

            foreach (var activity in activities.Reverse())
            {
                var vm = new ActivityViewModel(activity);
                activityViewModels.Add(vm);
            }

            ViewBag.Activities         = activityViewModels;
            ViewBag.IdeationReplyCount = ideationManager.GetIdeationReplyCount(platform.PlatformId);
            ViewBag.CommentCount       = ideationManager.GetCommentCount(platform.PlatformId);
            ViewBag.VoteCount          = ideationManager.GetTotalVoteCount(platform.PlatformId);
            ViewBag.IoTCount           = ioTManager.GetIotCountByPlatform(platform.PlatformId);

            ViewBag.ProjectVoteCount          = new List <int>();
            ViewBag.ProjectCommentCount       = new List <int>();
            ViewBag.ProjectIdeationReplyCount = new List <int>();

            var users = userManager.Users;
            var count = 0;

            foreach (var userCount in users)
            {
                if (userManager.GetClaimsAsync(userCount).Result.SingleOrDefault(c => c.Type == _subdomain) != null)
                {
                    count++;
                }
            }
            ViewBag.UserCount = count;

            User user = userManager.GetUserAsync(User).Result;

            if (user != null)
            {
                ViewBag.IsAdmin = userManager.IsUserAdminOrAbove(user, tenant);
            }
            else
            {
                ViewBag.IsAdmin = false;
            }

            return(View(platform));
        }